The Map object

Maps are like Python dictionaries. (I don't know how it's implemented at this point... as a hash table, or an associative array, or in some other way.)

Adding items to a map:

ages := Map clone
ages atPut("Hans", 33)
ages atPut("Kavi", 14)
ages atPut("Niffler", 2.5)

And retrieving them:

ages at("Niffler") println
#=> 2.5

Other methods:

Io> ages keys
#=> list("Niffler", "Kavi", "Hans")
Io> ages values
#=> list(2.5, 14, 33)

Io> ages hasKey("Hans")
#=> true
Io> ages hasKey("Fred")
#=> false
Io> ages size
#=> 3

There's also atIfAbsentPut, which adds an item but only if it's not already in the Map:

Io> ages atIfAbsentPut("Jessi", 18)
#=> 18
Io> ages atIfAbsentPut("Jessi", 45)
#=> 18
Io> ages at("Jessi")
#=> 18

Loop over the key/value pairs using the foreach method:

Io> ages foreach(key, value,
         writeln(key, " => ", value))
# prints:
Jessi => 18
Niffler => 2.5
Kavi => 14
Hans => 33