15 Jul 2013, 03:35

Vincent Ohprecio (1 post)

««««««< Book »»»»»»»>

Because we often need simple lists of key/value pairs, Elixir gives us a shortcut. If you write

[ name: "Dave", city: "Dallas", likes: "Programming" ]
Elixir converts it into a list of 2-value tuples:
[ {:name, "Dave"}, {:city, "Dallas"}, {:likes, "Programming"} ]

««««««« Shell »»»»»»»>

iex(57)> aoeu = [ name: "Dave", city: "Dallas", likes: "Programming" ]
[name: "Dave", city: "Dallas", likes: "Programming"]
iex(58)> aoeu
[name: "Dave", city: "Dallas", likes: "Programming"]
15 Jul 2013, 03:36

Dave Thomas (338 posts)

The shell is smart, and displays it as a keyword list…

17 Jul 2013, 14:31

Clint Shryock (6 posts)

Someone in IRC showed me inspect:

iex(71)> inspect([ name: "Dave", city: "Dallas", likes: "Programming" ], raw: true)  
"[{:name, \"Dave\"}, {:city, \"Dallas\"}, {:likes, \"Programming\"}]"
  You must be logged in to comment