daily pastebin goal
76%
SHARE
TWEET

[Perl 6] Using closures.

cwchen Nov 28th, 2017 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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";
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top