langur

hashes

These could also be called dictionaries, maps, or associative lists. There is no guaranteed order of elements.

Hash literals are built with a comma-delimited key/value pair list within curly braces, using a colon between each key and value. They are enclosed with curly braces. An empty hash may be generated with {:}.

{1: "first", 2: "second"} {"abc": 123, "def": 789}

Hashes may use strings or numbers for keys. Different key types may be used in the same hash.

Indexing a hash with 1.0 is the same as indexing with 1. (Numbers are simplified for hash keys.)

A hash value may be any langur data structure, and they may be mixed freely within a hash.

Hashes may be appended with the concatenation operator (tilde). Concatenation overwrites values for existing keys in the left operand with values having the same keys in the right operand.

{1: "first", 2: "second"} ~ {3: "third", 2: "new second"}

To add hashes together, but error out on duplicate keys, use the more() function.

more {1: "first", 2: "second"}, {3: "third", 2: "new second"} # throws exception because key 2 in each hash

The keys(), map(), more(), and less() functions may be useful in dealing with hashes.