Course of Raku / Essentials / Code blocks
Global variables
Let us create a variable before the code block:
my $x = 1;
{
$x = 42;
say $x;
}
say $x;
In this case, $x
is a global variable (it is located in the global scope), and the program prints 42
twice.
Course navigation
← Code blocks / Lexical scope | Code blocks / Local variables →
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська