int-bounds
ErrorsCollection

int-bounds

Synthesised documentation from type/Range

From type/Range

See Original text in context

proto method int-bounds(|)
multi method int-bounds()
multi method int-bounds($from is rw$to is rw --> Bool:D)

If the Range is an integer range (as indicated by is-int), then this method returns a list with the first and last value it will iterate over (taking into account excludes-min and excludes-max). Returns a Failure if it is not an integer range.

say (2..5).int-bounds;                            # OUTPUT: «(2 5)␤» 
say (2..^5).int-bounds;                           # OUTPUT: «(2 4)␤»

If called with (writable) arguments, these will take the values of the higher and lower bound and returns whether integer bounds could be determined from the Range:

if (3..5).int-boundsmy $minmy $max{
    say "$min$max" ; # OUTPUT: «3, 5␤» 
}
else {
    say "Could not determine integer bounds";
}