Tutorial by Examples

Maps are the Elixir key-value (also called dictionary or hash in other languages) type. You create a map using the %w{} syntax: %{} // creates an empty map %{:a => 1, :b => 2} // creates a non-empty map Keys and values can use be any type: %{"a" => 1, "b" => 2} ...
Keyword lists are tuples of key/value, generally used as options for a function call. [{:a, 1}, {:b, 2}] // creates a non-empty keyword list Keyword lists can have the same key repeated more than once. [{:a, 1}, {:a, 2}, {:b, 2}] [{:a, 1}, {:b, 2}, {:a, 2}] Keys and values can be any type: ...
Maps and keyword lists have different application. For instance, a map cannot have two keys with the same value and it's not ordered. Conversely, a Keyword list can be a little bit hard to use in pattern matching in some cases. Here's a few use cases for maps vs keyword lists. Use keyword lists wh...

Page 1 of 1