Documentation for method ASSIGN-KEY
assembled from the following pages:
Language documentation: Subscripts §
From Subscripts
(Subscripts) method ASSIGN-KEY §
multi method ASSIGN-KEY (::?CLASS: , )
Expected to set the element associated with $key
to the value $new
. Implementing this is entirely optional; if you don't, self.AT-KEY($key) = $new
is used instead, and if you do, you should make sure it has the same effect.
This is meant as an opt-in performance optimization, so that simple assignments %age<Claire> = 29
can operate without having to call AT-KEY
(which would have to create and return a potentially expensive container object).
Note that implementing ASSIGN-KEY
does not relieve you from making AT-KEY
an rw
method though, because less trivial assignments/modifications such as %age<Claire>++
will still use AT-KEY
.