Map module

This module contains types and functions to manipulate and build maps. A map is a data structure matching some values to some keys. Keys and values can be of any type except nil that has a special meaning. A map is both an associative table and an array. The value associated to a key is set or retrieved by using the “bracket” notation. For instance, a[k] returns the value associated to the key k from the map a. If there is no value associated to the given key, nil is returned. Setting the value of an existing key will overwrite the previous value associated to the key.

A map is implicitely created when inserting their first element. You can also declare a map explicitely with the builtin map() function or with the curly brackets notation { }.


a = { }; // Creates an empty map.
b = { 1, 2, 3, 5, 7, 11 }; // Creates a map with the first prime numbers.
c = map("Hello", "world", 3.14); // Creates a map with the builtin map function.
d[0] = "foobar"; // Creates a map implicitely and sets value "foobar" to index 0.

nbElements = b.count(); // Gets the number of values in the map `b`.
allKeys = b.keys();     // Returns a map containing all the keys of the map `b`.

For more details about map declarations or to learn how to manipulate maps, read the Map declaration section in Expressions and Values and types.

type map

This is the base type for maps.


Counts the number of values in the map.


Returns the values of the map in a new map.


Returns the keys of the map in a new map.


Adds the given value in the map with key equals to the largest integer key presents in the map plus one.