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

Quiz — Packages

What does the following program print?

module M {
    my $x = 5;
}

say $M::x.defined;
1False
0True
05
0An error

$x is declared with my, so it is lexical and never enters the M namespace. The path $M::x therefore finds nothing — an undefined value — and .defined is False. Only an our variable would be reachable this way.

Course navigation

Packages and modules   |   Namespaces and our