daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest May 18th, 2018 121 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/opt/rakudo-pkg/bin/perl6
  2.  
  3. #  printf "%s \n", 10/2/2.5;
  4.  
  5. my @aNumlist = <4 9 16 25>;
  6.  
  7. #printf "%s \n", @aNumlist.elems;
  8.  
  9. #say @aNumlist;
  10.  
  11. class DoComputations {
  12.     #has Int $x
  13.     #method addValue(Int myValue) {
  14.     method addValue( $myValue ) {
  15.         #return $myValue + $myValue;
  16.         return $myValue;
  17.     }
  18.  
  19. }
  20.  
  21. my $tmp = DoComputations.new;
  22.  
  23. #printf "%s \n", $tmp.addValue ();
  24. #say DoComputations.new.addValue(12);
  25.  
  26. #printf "%s \n", DoComputations.addValue:myValue(12);
  27.  
  28. say DoComputations.addValue: myValue =>12;
  29.  
  30. =====  OUTPUTS ====
  31.  
  32. Too few positionals passed; expected 2 arguments but got 1
  33.   in method addValue at ./lambada.pl line 14
  34.   in block <unit> at ./lambada.pl line 28
  35.  
  36.  
  37. === QUESTION HOW DO I PASS A VALUE TO A METHOD OF A CLASS? ===
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