Course of Raku / Advanced / Modules / Modules basics / Exercises / Read the constant

Solution: Read the constant

Here is a possible solution to the task.

Code

The program, read-pi.raku:

need Circle;

say $Circle::pi;

🦋 You can find both source files in the exercises/advanced/modules-basics/read-the-constant directory.

Output

$ raku -I. read-pi.raku
3.14

Comments

  1. need Circle loads the module but does not import any names, so a bare $pi would not be recognised.

  2. The our variable is reached through the module’s name, written as $Circle::pi.

Course navigation

Read the constant   |   Load at run time