Associative array

From Mario Fan Games Galaxy Wiki
Data Types
Array


 Merge.png It has been suggested that this article should be merged with Array.

See this article's talk page for more information.

Associative arrays (also hash or dictionary) are an extension of a normal array; instead of using a numeric index to access values, they use a string key. Generally, only one key of a given name can exist in an associative array.

Commonly, the dot syntax syntactic sugar is provided as an alternative means to access values by providing the key, such as array.key. Otherwise, the value is usually accessed by array["key"].

Languages may or may not sort the keys, e.g. alphabetically; as such, accessing a key's value by using a numeric index instead of a string can be unpredictable. In addition, some may not allow the simultaneous use of both numeric and string indexes, converting array[0] to array["0"].