Skip to content

Commit 23e56e3

Browse files
committed
Adds indirect invocation to syntax
And also adds preamble to example, instead of skipping test. Closes #2131
1 parent bfd3f57 commit 23e56e3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

doc/Language/syntax.pod6

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,11 +733,18 @@ are subroutines invoked against an object (i.e., a class instance).
733733
Within a method the special variable C<self> contains the object instance
734734
(see L<Methods|/language/classtut#Methods>).
735735
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+
>
737743
# Method invocation. Object (instance) is $person, method is set-name-age
738744
$person.set-name-age('jane', 98); # Most common way
739745
$person.set-name-age: 'jane', 98; # Precedence drop
740746
set-name-age($person: 'jane', 98); # Invocant marker
747+
set-name-age $person: 'jane', 98; # Indirect invocation
741748
=end code
742749
743750
For more information see L<functions|/language/functions>.

0 commit comments

Comments
 (0)