What would be the expected output from the following?
my $a = foo();
my $b;
{
my $x = 1;
sub get_x() { return $x; }
sub foo() { return &get_x; }
$b = foo();
}
my $c = foo();
say "a: ", $a();
say "b: ", $b();
say "c: ", $c();
As a followup question, what about...?
my @array;
for 1..3 -> $x {
sub get_x() { return $x; }
push @array, &get_x;
}
for @array -> $f { say $f(); }
Pm
