joyofelixir
joyofelixir copied to clipboard
Chapter 14: Show default arguments for functions
In Chapter 13, we will show the documentation for Map.get/2
, which has this title:
def get(map, key, default \\ nil)
The default \\ nil
syntax is new to readers as of this point. It should probably be introduced in Chapter 6.
Except:
a = fn (a \\ nil) -> "Hello #{a}" end
** (CompileError) iex:26: anonymous functions cannot have optional arguments
(stdlib) lists.erl:1354: :lists.mapfoldl/3
(elixir) src/elixir_fn.erl:19: :elixir_fn.expand/3
Probably something to show in Ch14 then.