in reply to Local for lexicals
Of course, in Perl, one doesn't really need "lambda". Hence a lambda which just returns the sub.sub lambda {$_[1]} our $x = 2; my $f = lambda $x => sub {$x ** 2}; say $f->(); { local $x = 3; say $f->(); } say $f->(); __END__ 4 9 4
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Local for lexicals
by JadeNB (Chaplain) on Aug 10, 2009 at 23:06 UTC | |
by JavaFan (Canon) on Aug 10, 2009 at 23:33 UTC | |
by LanX (Saint) on Aug 11, 2009 at 00:11 UTC | |
by JadeNB (Chaplain) on Aug 12, 2009 at 19:26 UTC |