Maps: Associative Key-Value Stores

Maps were made available from version R17 of Erlang.

Maps have the following properties:

  • The syntax of maps is similar to that of records, except the record name is omitted and the key-value separator is either => or :=.

  • Maps are associative collections of key-value pairs.

  • The keys in a map can be any fully ground Erlang term (fully grounded means that there are no unbound variables in the term).

  • The elements in a map are ordered by the keys.

  • Updating a map where the keys are not changed is a space-efficient operation.

  • Looking up the value of a key in a map is an efficient operation.

  • Maps have a well-defined order.

We’ll look at maps in more detail in the following sections.

The Semantics of Maps

Map literals ...

Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.