How to Choose Between Maps and Keyword Lists
Ask yourself these questions (in this order):
-
Do I want to pattern-match against the contents (for example, matching a dictionary that has a key of :name somewhere in it)?
If so, use a map.
-
Will I want more than one entry with the same key?
If so, you’ll have to use the Keyword module.
-
Do I need to guarantee the elements are ordered?
If so, again, use the Keyword module.
-
And, if you’ve reached this point:
Use a map.
Get Programming Elixir 1.3 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.