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


 
class Main
{
  public static Void main ()
  {
    // create a map which maps Ints to Strs, with given key-value pairs
    Int:Str map := [1:"alpha", 2:"beta", 3:"gamma"]
 
    // create an empty map
    Map map2 := [:]
    // now add some numbers mapped to their doubles
    10.times |Int i| 
    { 
      map2[i] = 2*i 
    }
 
  }
}
 