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->();
In reply to Re: Re: Help with the concept of closures.
by chromatic
in thread Help with the concept of closures.
by DigitalKitty
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |