Course of Raku / Advanced / Operators / Types of Raku operators / Exercises

Count up

Problem

Start with my $n = 9;. The postfix ++ operator has a subtle feature: as an expression it returns the value the variable held before the increment, then bumps the variable.

In a single say, print the result of $n++, and on the next line print $n itself, so the difference is visible.

Example

The program prints:

9
10

Solution

See the solution

Course navigation

Types of Raku operators   |   Solution: Count up