Documentation for method EXISTS-POS

Documentation for method EXISTS-POS, assembled from the following types:

language documentation Subscripts

From Subscripts

(Subscripts) method EXISTS-POS

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

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.