June 2022
Intermediate to advanced
130 pages
2h 45m
English
Remember, Elixir data structures can’t be updated. When we say “change” or “update”, we’re talking about returning a new changed map. Let’s look at a few techniques we can use to transform maps.
We’ll look at a convenient way to change one or more keys in a map using an expression called the map update syntax. Then we’ll look at a few functions in the Map API that transform maps. These are two ways to change one map.
We’ll also do our usual exploration through maps using the IEx console. We’ll look at the underlying data type and explore it a bit. Let’s get started.
The map update syntax works best when maps have a known set of keys. Say we have a map representing a person:
| | iex> person = %{first: "Joe" ... |
Read now
Unlock full access