ASSIGN-POS
ErrorsCollection

ASSIGN-POS

Synthesised documentation from language/subscripts

From language/subscripts

See Original text in context

multi method ASSIGN-POS (::?CLASS:D: $index$new)

Expected to set the element at position $index to the value $new. Implementing this is entirely optional; if you don't, self.AT-POS($index) = $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 like @numbers[5] = "five" can operate without having to call AT-POS (which would have to create and return a potentially expensive container object).

Note that implementing ASSIGN-POS does not relieve you from making AT-POS an rw method though, because less trivial assignments/modifications such as @numbers[5]++ will still use AT-POS.