September 2017
Beginner
402 pages
9h 52m
English
The so operator converts the operand to a Boolean value and returns it, as shown in the following example:
say so 0; # Falsesay so 42; # Truesay so True; # True
The ? operator has a higher precedence than the so operator.
The so routine also exists as a method of the Mu class and can be called like $var.so on a variable. (Classes are discussed in Chapter 8, Object-Oriented Programming; Mu is one of the classes on the top of Perl 6 class hierarchy.) So, the following code can be read as an English phrase 'If something is so, then do the following':
my $smth = True;if $smth.so { say 'True';}