Course of Raku / Essentials / Ranges
Matching against a range
Take a range and a variable with an integer value in it:
my $r = 1..10;
my $v = 7;
Using the smart-match operator ~~
, you can check if the value is within the range:
say $v ~~ $r;
In the shown example, the condition is True
, so the program prints True
.
Course navigation
← Ranges / Excluding endpoints | 💪 Exercise: If the number is within the limits →
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська