On Sat, Jul 12, 2008 at 09:52:34PM -0500, Patrick R. Michaud wrote: > 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();
If I'm reading the current version of S04 correctly, I'm guessing the above will produce a: Use of undefined value b: 1 c: 1 > 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(); } This one would output "1\n2\n3\n". Are my interpretations correct here? Pm