AT-KEY
ErrorsCollection

AT-KEY

Synthesised documentation from type/Associative language/subscripts

From type/Associative

See Original text in context

method AT-KEY(\key)

Should return the value / container at the given key.

class What { method AT-KEY(\key{ 42 }};
say What.new{33}# OUTPUT: «42␤» 

From language/subscripts

See Original text in context

multi method AT-KEY (::?CLASS:D: $key)

Expected to return the element associated with $key. This is what postcircumfix { } normally calls.

If you want an element to be mutable (like they are for the built-in Hash type), you'll have to make sure to return it in the form of an item container that evaluates to the element's value when read, and updates it when assigned to. Remember to use return-rw or the is rw routine trait to make that work; see the example.

On the other hand if you want your collection to be read-only, feel free to return non-container values directly.