Course of Raku / Essentials / Scalar variables

Declaring a variable

Variables must be announced before you use them. Raku has special declarators for this. To declare a variable, use my as shown below:

my $name;

Having that said, you introduced a new variable, which keeps no payload so far. But it is already known to the compiler to identify it when it sees the same name later in the program.

More than one variable

You can declare two or more variables using the same my declarator:

my ($x, $y);

Practice

Complete the quizzes that cover the contents of this topic.

Course navigation

Scalar variables   |   Scalar variables / Assigning a value


💪 Or jump directly to the exercises to this section.