πŸ“˜ Shortcut operator && in Perl 6

πŸ“˜ Shortcut operator && in Raku

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


&& returns the first of the operands, which, after being converted to a Boolean value, becomes False. If none are False, then the last element is returned. Please note that the result is not a Boolean value but the value of one of the operands (unless they are Boolean already).

say 10 && 0; # 0
say 0 && 10; # 0Β 
say 12 && 3.14 && "" && "abc"; # empty string

The operator stops its work as soon as the acceptable value has been found. The values of the rest of the operands will not be calculated. That is why the operator belongs to the group of shortcut operators.

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