BrowserREPL-button-tip-on BrowserREPL-button-tip-off

EditButtonTip 2024-05-18

class X::OutOfRange

Error due to indexing outside of an allowed range

class X::OutOfRange is Exception { }
Code

General error when something (for example an array index) is out of an allowed range.

For example

say 42[2];
CATCH { default { put .^name, ': ', .Str } };
# OUTPUT: «X::OutOfRange: Index out of range. Is: 2, should be in 0..0␤»
Code

since scalars generally act as a one-element list.

Methods§

method what§

method what(--> Str:D)
Code

Verbal description of the thing that was out of range (e.g. "array index", "month").

method got§

method got()
Code

Returns the object that was considered out of range (often an integer)

method range§

method range(--> Range:D)
Code

Returns a Range object describing the permissible range for the object returned from .got.

method comment§

method comment(--> Str)
Code

Returns an additional comment that is included in the error message.