We cover:

Chapter 6
Modules and Named Functions

Once a program grows beyond a couple of lines, you’ll want to structure it. Elixir makes this easy. You break your code into named functions and organize these functions into modules. In fact, in Elixir named functions must be written inside modules.

Let’s look at a simple example. Navigate to a working directory and create an Elixir source file called times.exs.

mm/times.exs
 defmodule​ Times ​do
 def​ double(n) ​do
  n * 2
 end
 end

Here we have a module named Times. It contains a single function, double. Because our function takes a single argument and because the number of arguments forms part of the way we identify Elixir functions, you’ll see this function name written as double/1.