Passing Functions as Arguments
Explore how to pass functions as arguments in Elixir programming, learn to create and invoke anonymous functions, and understand the use of the & shorthand notation for concise function expressions.
We'll cover the following...
We'll cover the following...
Functions are just values, so we can pass them to other functions. We use this ability of passing functions around pretty much everywhere in Elixir code. Let’s look at an example:
iex> times_2 = fn n -> n * 2 end
#Function<12.17052888 in :erl_eval.expr/5>
...