MapsealedThe insertion-ordered dictionary, written #{'a': 1 'b': 2}. Any value can be a key, and iteration, printing, and serialization keep the order entries were added — a parse → generate round-trip doesn't reshuffle a document.
Scalars, strings, and other content values key by value; a user instance keys by identity unless its class overrides both hash and ==: (its hash runs once, at insert); the mutable built-in collections key by identity. Reading an absent key answers nil. A map with a checked value type comes from Map.of: / ensure:.
Maps are iterable: the iteration element is a key/value pair.
A fresh empty Map, the Map class default.
A Map built from an iterable of KeyValuePairs (as produced by iterating a Map), in iteration order.
Map.fromPairs:(#{'a': 1 'b': 2}.list.select:{ |p| p.value > 1 }) "* -> #{'b': 2}
A fresh empty map — the same value the #{} literal builds.
Always refused: a Map has no instance fields for a new: config block to set. Construct with #{}, Map.new, or Map.of:.
A fresh empty map tagged with a VALUE class: every later at:put: checks the value (keys stay unrestricted), raising a catchable TypeError on a mismatch.
(Map.of:Integer).at:'n' put:1 "* -> #{'n': 1}
Entry-wise equality: true when the other value is a Map of the same size holding, for every key here, an == value there — insertion order does not matter. Anything that is not a Map answers false.
#{'a': 1 'b': 2} == #{'b': 2 'a': 1} "* -> true
The value stored under a key, or nil when the key is absent (use containsKey?: to tell the two apart).
#{'a': 1 'b': 2}.at:'a' "* -> 1
Store a value under a key — replacing what an existing key holds, appending a new entry (last in iteration order) otherwise. Answers the receiver. On a tagged map (Map.of:) the value is checked first.
#{'a': 1}.at:'b' put:2 "* -> #{'a': 1 'b': 2}
Destructure into a block: each parameter is looked up as a key — the parameter's name as a String key first, then as a Symbol key — and an absent key binds nil. Answers the block's value.
#{'w': 3 'h': 4}.bind:{ |w h| w * h } "* -> 12
True when the key is present — the way to tell a stored nil from an absent key (at: answers nil for both).
#{'a': 1}.containsKey?:'a' "* -> true
The number of entries.
#{'a': 1 'b': 2}.count "* -> 2
Iterate in insertion order (the Map preserves it). The iteration element is a key/value PAIR, not the value type (GENERICS_ARCH 4.4).
The checked VALUE type as a Symbol, or nil for an ordinary untagged map.
(Map.of:Integer).elementType "* -> Integer
A fresh empty map like the receiver — value tag included. The species hook the Iterate mixin uses, so transforms of a checked map stay checked.
Check every value against a class and answer a NEW map carrying that value tag; a non-matching value raises a catchable TypeError naming the offending key's class. The receiver itself stays untagged.
The keys as a List, in insertion order.
#{'a': 1 'b': 2}.keys "* -> #(a b)
Remove a key's entry, answering the removed value — or nil (removing nothing) when the key is absent. The remaining entries keep their order.
#{'a': 1 'b': 2}.remove:'a' "* -> 1
The values as a List, in insertion order (index-aligned with keys).
#{'a': 1 'b': 2}.values "* -> #(1 2)