Course of Raku / Essentials

Scalar variables

So far, the programs we saw had hardcoded text strings. Let us introduce a bit of freedom and let the program use variables.

There are a few types of variables in Raku. A variable is a container that can keep some data in it. We’ll start with the simplest containers that can keep only a single value. Such containers are called scalars or scalar variables. A variable has a name prefixed with a special indicator that tells about the container’s nature. That indicator is a character called sigil. For scalar containers, such a sigil is a dollar character $.

Here are a couple of examples of scalar variables:

$name

$age

Exercises

This section contains 4 exercises. Examine all the topics of this section before going to the coding practice.

  1. Greet a person
  2. The answer to life, the Universe and everything
  3. Swap values
  4. Correct the identifiers

Course navigation

Comments / Embedded comments   |   Declaring a variable

Translations of this page: EnglishDeutschEspañolItalianoLatviešuNederlandsБългарскиРусскийУкраїнська