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


BEGIN {
  a["red"] = 0xff0000
  a["green"] = 0x00ff00
  a["blue"] = 0x0000ff
  for (i in a) {
    printf "%8s %06x\n", i, a[i] 
  }
  # deleting a key/value
  delete a["red"]
  for (i in a) {
    print i
  }
  # check if a key exists
  print ( "red" in a )   # print 0
  print ( "blue" in a )  # print 1
}