Course of Raku / Advanced / Operators / Traits and pragmas 🆕 / Pragmas
Quiz — Pragmas
With Raku’s default strict pragma in force, what happens
when you assign to a variable you never declared, as in
$x = 42?
| 1 | It is a compile-time error |
| 0 | It silently creates $x |
| 0 | It prints a warning but runs |
| 0 | It sets $x to Nil |
strict is on by default and requires every variable to
be declared with my first, so a bare $x = 42
fails to compile — Variable ‘$x’ is not declared. Turning the
pragma off with no strict would let the assignment
through.
Course navigation
← Pragmas | A writable parameter →