Course of Raku / Objects, I/O, and exceptions / Classes and objects / Class methods / Exercises

Kilometres to miles

Problem

Define a class Converter with a class method km-to-miles that takes a number of kilometres and returns the distance in miles (multiply by 0.621).

Call the method on the class for 10 kilometres, and print the result.

Example

The program prints:

6.21

Solution

See the solution

Course navigation

Solution: A formula on the class   |   Solution: Kilometres to miles