Raku Books / Perl 6 at a Glance / Perl 6 Essentials / Built-in types
Bool
The usage of the Bool variables is straightforward
although there are some details about which you might want to know. The
Bool type is a built-in enumeration and provides two values:
True and False (or, in a full form,
Bool::True and Bool::False). It is permissible
to increment or decrement the Boolean variables:
my $b = Bool::True;
$b--;
say $b; # prints False
$b = Bool::False;
$b++;
say $b; # TrueThe Perl 6 objects (namely, all variables) contain the
Bool method, which converts the value of the variable to
one of the two Boolean values:
say 42.Bool; # True
my $pi = 3.14;
say $pi.Bool; # True
say 0.Bool; # False
say "00".Bool; # TrueSimilarly, you may call the Int method on a variable and
get the integer representation of the Boolean values (or values of any
other types):
say Bool::True.Int; # 1Course navigation
← Typed variables | Int →