variable Scope

Documentation for variable Scope assembled from the following types:

language documentation Perl 6 from Ruby - Nutshell

From Perl 6 from Ruby - Nutshell

(Perl 6 from Ruby - Nutshell) variable Scope

For local variables, Ruby uses implicit variable declaration upon assignment and limited to the current block. In Ruby the content of an if or while built-in construct is not a block or scope.

Perl 6 uses explicit scope indicators, and never creates variables implicitly. Every place you see { ... } is a scope, including the body of a conditional or loop. The commonly used scope declarations:

foo = 7        # Ruby, variable scope is defined by first assignment and 
               # extends to the end of the current block 
my  $foo = 7;   # Perl 6, lexical scoped to the current block 
our $foo = 7;   # Perl 6, package scoped 
has $!foo = 7;  # Perl 6, instance scoped (attribute)