joyofelixir icon indicating copy to clipboard operation
joyofelixir copied to clipboard

Chapter 14: Show default arguments for functions

Open radar opened this issue 6 years ago • 1 comments

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.

radar avatar Jan 02 '19 21:01 radar

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.

radar avatar Jan 02 '19 21:01 radar