File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -733,11 +733,18 @@ are subroutines invoked against an object (i.e., a class instance).
733
733
Within a method the special variable C < self > contains the object instance
734
734
(see L < Methods|/language/classtut#Methods > ).
735
735
736
- = begin code :skip-test
736
+ = begin code :preamble<class Person {
737
+ has Int $.age;
738
+ has Str $.name;
739
+ method set-name-age( $!name, $!age ) {}
740
+ }
741
+ my Person $person .= new;
742
+ >
737
743
# Method invocation. Object (instance) is $person, method is set-name-age
738
744
$person.set-name-age('jane', 98); # Most common way
739
745
$person.set-name-age: 'jane', 98; # Precedence drop
740
746
set-name-age($person: 'jane', 98); # Invocant marker
747
+ set-name-age $person: 'jane', 98; # Indirect invocation
741
748
= end code
742
749
743
750
For more information see L < functions|/language/functions > .
You can’t perform that action at this time.
0 commit comments