Maps are used to store key/value pairs. Maps are defined with curly brackets prefixed with a percent %{}.


# Define a map
map = %{stuff: "stuff", things: "things"}

# Define a map with the hash rocket syntax
map = %{:stuff => "stuff", :things => "things"}

# Create a map from a list of tuples
map =[{:stuff, "stuff"}, {:things, "things"}])


  • It is convention to use atoms as keys for maps.
  • When an atom is used for a key the value can be retrieved with the . syntax. IE: map.stuff