Course of Raku / Essentials / Boolean type

Boolean operations

You can do all standard operations with Boolean values: Boolean AND, OR, and exclusive OR (or XOR):

say False && True; # AND
say False || True; # OR
say False ^^ True; # XOR

This program prints the following results:

False
True
True

Negation

To negate a Boolean value, use the prefix operator !:

say !False; # True

Boolean values can be stored in scalar variables:

my $did = True;
my $didn't = !$did;

Practice

Complete the quiz that covers the contents of this topic.

Course navigation

Boolean type   |   Boolean type / Boolean operations with other types


💪 Or jump directly to the exercises to this section.