A collection of cheat sheets.
Hosted on GitHub Pages — Theme by mattgraham
%{ key1 => value1,
key2 => value2,
atom_key: value3 } # Shorthand notation for atom keys
# Returns nil on missing key
value = map[key]
# If key is atom, raises on missing key
value = map.key
%{key: x} = %{key: 5}
# x is now bound to 5
# Only works for existing keys
map = %{x: 1, y: 2}
updated = %{ map | y: 3 }
# => updated is now %{ x: 1, y: 3 }