Arrays and Hashes

Array

An array is an ordered sequence of items (‘elements’) (see: http://en.wikipedia.org/wiki/Array_data_type)

Each element can be of any data type.

E.g.

array1

array2

You may also have another array or a hash as an element of an array, in this example we have an array of arrays:

matrix-example

You can create an array in a formula using the ARRAY function. E.g.

ARRAY(1, 2, 3)

Hash

A hash is an associative array (http://en.wikipedia.org/wiki/Associative_array), or in other words a mapping of keys to values.

E.g.

Names to ages

hash1

A hash is designed to allow you to get the value associated with a key very quickly.

You can do this in a formula:

HASH_GET($hash, "Steph") // result is 10

Hashes are also used in several places to pass in named arguments to functions, for example in DB_LOOKUP.

To create a hash in a formula use the HASH function. E.g.

HASH("name", "Alfred", "age", 24)

Related Articles