langur

hashes

These could also be called hashes, 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.)

Hashes may contain any other langur data structures, and they may be mixed freely.

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.