In Subscripts§
See primary documentation in context for method AT-POS
multi method AT-POS (::?CLASS: )
Expected to return the element at position $index
. This is what postcircumfix [ ]
normally calls.
If you want an element to be mutable (like they are for the built-in Array
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.
In role Positional§
See primary documentation in context for method AT-POS
method AT-POS(\position)
Should return the value / container at the given position.
In role Sequence§
See primary documentation in context for method AT-POS
multi method AT-POS(::?CLASS: Int )multi method AT-POS(::?CLASS: int )
Returns the element at position $idx
in the cached sequence.
In Range§
See primary documentation in context for method AT-POS
multi method AT-POS(Range: int \pos)multi method AT-POS(Range: int \pos)
Checks if the Int
position exists and in that case returns the element in that position.
say (1..4).AT-POS(2) # OUTPUT: «3»
In IterationBuffer§
See primary documentation in context for method AT-POS
multi method AT-POS(IterationBuffer: int )multi method AT-POS(IterationBuffer: Int )
Returns the value at the given element position, or Mu
if the element position is beyond the length of the IterationBuffer
, or an error will be thrown indicating the index is out of bounds (for negative position values).