Advertisement
cwchen

[Perl 6] Using closures.

Nov 28th, 2017
3,563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 6 0.20 KB | None | 0 0
  1. sub number {
  2.     my $n = -1;
  3.    
  4.     sub {
  5.         $n++;
  6.         $n;
  7.     }
  8. }
  9.  
  10. my $f = number();
  11.  
  12. $f() == 0 or die "Wrong value";
  13. $f() == 1 or die "Wrong value";
  14. $f() == 2 or die "Wrong value";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement