Wand Maker
Wand Maker

Reputation: 18772

Elixir - Difference between keyword lists and maps

Just started with Elixir book by Dave Thomas.

It talks about two concepts:

Keyword lists

[ name: "Dave", city: "Dallas", likes: "Programming" ]

Maps

states = %{ "AL" => "Alabama", "WI" => "Wisconsin" }

When would you choose one over the other?

Upvotes: 9

Views: 1602

Answers (1)

José Valim
José Valim

Reputation: 51439

There is a chapter in the getting started guide with a quick overview: http://elixir-lang.org/getting-started/maps-and-dicts.html

To sum it up, keyword lists are used for options or when you need to preserve user ordering. For storing actual data, use maps.

Upvotes: 11

Related Questions