in reply to Re: Help with the concept of closures.
in thread Help with the concept of closures.
It's not a copy. It's the same variable.
sub make_closures { my $value = shift; return sub { $value++ }, sub { print "$value\n" }, sub { $value-- } +; } my ($increment, $display, $decrement) = make_closures( 3 ); $display->(); $increment->(); $display->(); $decrement->(); $display->();
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Help with the concept of closures.
by bobn (Chaplain) on Jul 06, 2003 at 03:21 UTC | |
by chromatic (Archbishop) on Jul 06, 2003 at 04:37 UTC | |
by bobn (Chaplain) on Jul 06, 2003 at 05:05 UTC | |
by bobn (Chaplain) on Jul 07, 2003 at 22:47 UTC |