perl6 -e '100 ~~ ^100' returns False, where it looks like to me it should return True, as 100 is in the range between 0 and 100. Is this a part of the design of the Range class that I'm just not understanding here or is this a bug?
The syntax ^100 is short-hand for 0 ..^ 100 and the ^ means "excluding". 0 ..^ 100 is actually the numbers 0 through 99. That's because with ^100 you get a list with exactly 100 elements - which is very useful for for loops.
Don't forget you can output the whole list with say (^100).list.
In addition to that, there's also ^.. and ^..^ which exclude the first element or the first and last element.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With