πŸ“˜ Prefix operator ^ in Perl 6

πŸ“˜ Prefix operator ^ in Raku

N. B. Perl 6 has been renamed to Raku. Click to read more.


^ is a range-creating operator or the so-called upto operator. It creates a range (which is an object of the Range type) from 0 up to the given value (not including it).

.print for ^5; # 01234

This code is equivalent to the following, where both ends of the range are explicitly specified:

.print for 0..4; # 01234

Leave a Reply

Your email address will not be published. Required fields are marked *

Retype the CAPTCHA code from the image
Change the CAPTCHA codeSpeak the CAPTCHA code