📘 Shortcut operator ^^ in Perl 6

📘 Shortcut operator ^^ in Raku

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


^^ returns an operand that is True in a Boolean context and that is, at the same time, the only one in the given list. If nothing is found, Nil is returned. As soon as the operator sees the second True value, it stops evaluating the rest, because the result is already known.

say 0 ^^ '' ^^ "abc" ^^ -0.0;  # abc
say 0 ^^ '' ^^ "abc" ^^ -10.0; # Nil

Leave a Reply