Course of Raku / Advanced / Modules / Packages and namespaces 🆕 / Exercises / An our variable
Solution: An our variable
Here is a possible solution to the task.
Code
package Config {
our $port = 8080;
my $secret = 42;
}
say $Config::port;
say $Config::secret.defined;🦋 You can find the source code in the file our-variable.raku.
Output
8080
FalseComments
our $portbecomes part of theConfignamespace, so it is reachable from outside as$Config::port, printing8080.my $secretis lexical — private to the package block — so it is not in the namespace. The path$Config::secretfinds nothing, an undefined value, so.definedisFalse. This is the differenceourmakes.
Course navigation
← An our variable | A package →