In Subscripts§
See primary documentation in context for method EXISTS-POS
multi method EXISTS-POS (::?CLASS: )
Expected to return a Bool indicating whether or not there is an element at position $index
. This is what postcircumfix [ ]
calls when invoked like @foo[42]:exists
.
What "existence" of an element means, is up to your type.
If you don't implement this, your type will inherit the default implementation from Any
, which returns True for 0 and False for any other index - which is probably not what you want. So if checking for element existence cannot be done for your type, add an implementation that fails or dies, to avoid silently doing the wrong thing.
In role Positional§
See primary documentation in context for method EXISTS-POS
method EXISTS-POS(\position)
Should return a Bool
indicating whether the given position actually has a value.
In role Sequence§
See primary documentation in context for method EXISTS-POS
multi method EXISTS-POS(::?CLASS: Int )multi method EXISTS-POS(::?CLASS: int )
Returns a Bool
indicating whether there is an element at position $idx
in the cached sequence.
In Range§
See primary documentation in context for method EXISTS-POS
multi method EXISTS-POS(Range: int \pos)multi method EXISTS-POS(Range: Int \pos)
Returns True
if pos
is greater than or equal to zero and lower than self.elems
. Returns False
otherwise.
say (6..10).EXISTS-POS(2); # OUTPUT: «True»say (6..10).EXISTS-POS(7); # OUTPUT: «False»