Course of Raku / Essentials


Ranges in Raku generate lists of sequential items.

In the simplest case, a range is a list of incrementing integers numbers. To create a range, use the .. operator and the two values that define the minimum and maximum values of the range:

1 .. 5

Spaces around the operator are optional. The following construction can be written as:


While a range is a mean to generate lists, it is still a single object, so it can be saved in a scalar variable:

my $r = 1 .. 5;

Not only numbers

It is possible to construct a range from other data types, for which Raku knows how to increment them. For example:

my $letters = 'a' .. 'z';

Ranges are objects of their own data type in Raku. The type of the variable $r is Range.


This section contains an exercise, which you are supposed to do after studying all the topics of this section.

💪 If the number is within the limits

Course navigation

Boolean type / Boolean operations with other types   |   Excluding endpoints