small medium large xlarge

Generic-user-small
28 Sep 2014, 18:21
Bhaskar Maddala (1 post)

Snippet from the book

You can also leave off the brackets if a keyword list appears as the last item in any context where a list of values is expected.
iex> [1, fred: 1, dave: 2]
[1, {:fred, 1}, {:dave, 2}]
iex> {1, fred: 1, dave: 2}
{1, [fred: 1, dave: 2]}

I cannot figure out why the second statement is a list of 2-tuple and not the same as the first, what exactly in the context here implies that a list of values is expected?

You must be logged in to comment