Advertisement
cwchen

[Perl 6] Parameters with side effects.

Nov 15th, 2017
1,256
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sub add-one($n is rw) {
  2.     $n += 1;
  3.     $n;
  4. }
  5.  
  6. my $n = 3;
  7. add-one($n) == 4 or die "Wrong value";
  8. $n == 4 or die "Wrong value";
Advertisement
RAW Paste Data Copied
Advertisement