The Process Dictionary
Each process in Erlang has its own private data store called the process dictionary. The process dictionary is an associative array (in other languages this might be called a map, hashmap, or hash table) composed of a collection of keys and values. Each key has only one value.
The dictionary can be manipulated using the following BIFs:
put(Key, Value) -> OldValue.
-
Add a
Key
,Value
association to the process dictionary. The value ofput
isOldValue
, which is the previous value associated withKey
. If there was no previous value, the atomundefined
is returned. get(Key) -> Value.
-
Look up the value of
Key
. If there is aKey
,Value
association in the dictionary, returnValue
; otherwise, return the atomundefined
. get() -> ...
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.