Passing Functions as Arguments
Learn how you can pass functions as a parameter in other functions.
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>
...