Course of Raku / Advanced / Operators / User-defined operators / Exercises

A squaring operator

Problem

An operator’s symbol can be any character, including a Unicode one. Define a postfix operator ² that squares its operand, so that means 5 ** 2. Then print .

Example

The program prints:

25

Solution

See the solution

Course navigation

Solution: Percent-of operator   |   Solution: A squaring operator