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

An our variable

Problem

Only our makes a name visible outside its package; my keeps it private. Create a package Config with an our variable $port set to 8080 and a my variable $secret set to 42. From outside, print $Config::port, and then print whether $Config::secret is defined — it should not be, because a my variable is not part of the namespace.

Example

The program prints:

8080
False

Solution

See the solution

Course navigation

Namespaces and our   |   Solution: An our variable