Course of Raku / Essentials / Control flow 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.
Practice
Complete the quiz that covers the contents of this topic.
Course navigation
← Quiz — Lexical scope | Quiz — Global variables →
Translations of this page: English • Deutsch • Español • Italiano • Latviešu • Nederlands • Български • Русский • Українська