3.10 Map
A map is a compound data type with a variable number of key-value associations:
- #{Key1=>Value1,...,KeyN=>ValueN}
Each key-value association in the map is called anassociation pair. The key and value parts of the pair arecalled elements. The number of association pairs is said to be the size of the map.
There exists a number of BIFs to manipulate maps.
Examples:
- 1> M1 = #{name=>adam,age=>24,date=>{july,29}}.
- #{age => 24,date => {july,29},name => adam}
- 2> maps:get(name,M1).
- adam
- 3> maps:get(date,M1).
- {july,29}
- 4> M2 = maps:update(age,25,M1).
- #{age => 25,date => {july,29},name => adam}
- 5> map_size(M).
- 3
- 6> map_size(#{}).
- 0
A collection of maps processing functions can be found in maps manual page in STDLIB.
Read more about maps in Map Expressions.
Note
Maps are considered to be experimental during Erlang/OTP R17.