Task

The goal is to create an associative array (also known as a dictionary, map, or hash).



Related tasks:

 Associative arrays/Iteration
 Hash from two arrays


See also

 Array
 Associative array: Creation, Iteration
 Collections
 Compound data type
 Doubly-linked list: Definition, Element definition, Element insertion, List Traversal, Element Removal
 Linked list
 Queue: Definition, Usage
 Set
 Singly-linked list: Element definition, Element insertion, List Traversal, Element Removal
 Stack


h = [:]  #Empty hash
 
h[:a] = 1  #Assign value
h[:b] = [1 2 3] #Assign another value
 
h2 = [a: 1, b: [1 2 3], 10 : "ten"]  #Initialized hash
 
h2[:b][2]  #Returns 3