Re: S04-related closure question
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(); >
S04-related closure question
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