Todd, are you looking for a range smartmatch, or possibly the
".in-range" method (Rakudo-only, below)?

> my $u = 248
248
> say (-128..127).in-range($u);
Value out of range. Is: 248, should be in -128..127
  in block <unit> at <unknown file> line 1

> my int8 $v = 0xF8;
-8
> say (-128..127).in-range($v);
True
>

"In Rakudo only, you can use the in-range method for matching against
a range, which in fact is equivalent to smartmatch except it will
throw an exception when out of range, instead of returning False... ."

https://docs.raku.org/type/Range

On Tue, Jan 28, 2020 at 12:06 PM ToddAndMargo via perl6-users
<perl6-us...@perl.org> wrote:
>
> On 2020-01-28 11:59, Trey Harris wrote:
> >
> >
> > On Tue, Jan 28, 2020 at 14:55 ToddAndMargo via perl6-users
> > <perl6-us...@perl.org <mailto:perl6-us...@perl.org>> wrote:
> >
> >     No I am really confused:
> >
> >     What part of
> >
> >           my int8 $u = 0xF8; $u.range
> >
> >     is not following
> >
> >           method range(--> Range:D)
> >
> >     ?
> >
> > Unless you’re getting the line `method range(--> Range:D)` from
> > somewhere else, you’re looking at
> > https://docs.raku.org/routine/range, which says
> >
> >  > Documentation for method |range| assembled from the following types:
> >
> >  > class X::OutOfRange <https://docs.raku.org/routine/range#___top>
> >
> > `int8` is not an `X:OutOfRange` object (which is an Exception), so it
> > can’t participate in the method you reference.
> >
>
> Okay, I think I get it.  I missed the "X:OutOfRange"
> and expected the qualifier to be in the definition line.
>
> What exactly is "X:OutOfRange" anyway?

Reply via email to