Map Traps

Let’s explore some potential map traps we might run into.

These are some of the traps we might fall into if we’re not careful. Don’t be fooled by the fact that iex sorts small maps in the console for convenience. We cannot count on this ordering! If we need to enforce order, we should use lists.

Keyword lists

Keyword lists were the maps in Elixir before we had true maps. They are lists of two tuples, each with an atom key and any type for a value. They are preferred over maps due to the following function options they provide:

...