Module and Function Basics
Elixir is a functional language, so—as you would expect—the work of an Elixir application is done in functions. Functions take input data, process it according to the function’s code, and then return a result. Modules are containers of functions that you have grouped together. They are mainly used as an organizational tool.
We are talking about modules and functions at the same time because they go hand-in-hand with each other. A module doesn’t serve a purpose without functions, and functions need a module to exist in.
The main purpose of modules is to hold functions, but they actually do more than this. Later in this chapter, we’ll look at additional syntax that’s available to modules.
We’ll cover two types of functions ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access