Hash (associative array)

Hash, or associative array, allows storing associations between string keys and some values. Hash is created automatically-when a variable is assigned or a method is called-the following way:

$hash_name[
    $.key1[value]
    $.key2[value]
    . . .
    $.keyN[value]
]

or

^method[
    $.key1[value]
    $.key2[value]
    . . .
    $.keyN[value]
]

You can also create an empty hash or a copy of another hash. See "Creating an empty hash or copying existing hash". Hash remembers the order, in which elements where added.

To retrieve a value stored in a hash key use construction:

$hash_name.key

Hash allows building multi-level structures, for example,
hash of hash where key values would be other hashes. Example:

$name[
    $.key1_of_level1[$.key1_of_level2[value]]
    . . . 
    $.keyN_of_level1[$.keyN_of_level2[value]]
]



Copyright © 1997–2021 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 28.01.2021