May 2018
Intermediate to advanced
412 pages
9h 3m
English
We cover:
Elixir is a functional language, so it’s no surprise functions are a basic type.
An anonymous function is created using the fn keyword.
| | fn |
| | parameter-list -> body |
| | parameter-list -> body ... |
| | end |
Think of fn…end as being a bit like the quotes that surround a string literal, except here we’re returning a function as a value, not a string. We can pass that function value to other functions. We can also invoke it, passing in arguments.
At its simplest, a function has a parameter list and a body, separated by ->.
For example, the following defines a function, binding it to the variable sum, and then ...
Read now
Unlock full access