Course of Raku / Advanced / Modules / Packages and namespaces 🆕 / Exercises

A package

Problem

Create a package Temperature that groups together two things: an our variable $freezing set to 0, and an our subroutine fahrenheit that converts a Celsius value to Fahrenheit (multiply by 9/5 and add 32). From outside the package, print the freezing point, then print the Fahrenheit value of 100 degrees Celsius.

Example

The program prints:

0
212

Solution

See the solution

Course navigation

Solution: An our variable   |   Solution: A package