A keyword is a list of tuples where the first element of the tuple is an atom and the second element can be any value.
A keyword may have duplicated keys so it is not strictly
a dictionary. However most of the functions in this module
behave exactly as a dictionary and mimic the API defined
by the Dict
behaviour.
For example, Keyword.get/3
will get the first entry matching
the given key, regardless if duplicated entries exist.
Similarly, Keyword.put/3
and Keyword.delete/3
ensure all
duplicated entries for a given key are removed when invoked.
A handful of functions exist to handle duplicated keys, in
particular, Enum.into/2
allows creating new keywords without
removing duplicated keys, get_values/2
returns all values for
a given key and delete_first/2
deletes just one of the existing
entries.
Since a keyword list is simply a list, all the operations defined
in Enum
and List
can be applied.