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

Average operator

Problem

Define an infix operator avg that returns the average of its two operands. Then use it to print the average of 4 and 10.

Example

The program prints:

7

Solution

See the solution

Course navigation

User-defined operators   |   Solution: Average operator