Skip to content

Commit b2bda56

Browse files
committed
Improve doc of postfix:<.+> and postfix:<.*>
Close #1421. Co. rakudo/rakudo#1754
1 parent 113ab80 commit b2bda56

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

doc/Language/operators.pod6

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -637,19 +637,39 @@ Technically, not a real operator; it's syntax special-cased in the compiler.
637637
X«|postfix .+»
638638
=head2 postfix C«.+»
639639
640-
C<$invocant.+method> calls all methods called C<method> from C<$invocant>,
641-
and returns a L<List> of the results. Dies if no such method was found.
640+
C<$foo.+meth> walks the MRO and calls all the methods called C<meth> and submethods called C<meth> if the type is the same as type of C<$foo>.
641+
Those methods might be multies, in which case the matching candidate
642+
would be called.
642643
643-
Technically, not a real operator; it's syntax special-cased in the compiler.
644+
After that, a L<List> of the results are returned. If no such method was found,
645+
it throws a L<X::Method::NotFound> exception.
646+
647+
class A {
648+
method foo { say "from A"; }
649+
}
650+
class B is A {
651+
multi method foo { say "from B"; }
652+
multi method foo(Str) { say "from B (Str)"; }
653+
}
654+
class C is B is A {
655+
multi method foo { say "from C"; }
656+
multi method foo(Str) { say "from C (Str)"; }
657+
}
658+
659+
say C.+foo; # OUTPUT: «from C␤from B␤from A␤(True True True)␤»
644660
645661
X«|postfix .*»
646662
=head2 postfix C«.*»
647663
648-
C<$invocant.*method> calls all methods called C<method> from C<$invocant>,
649-
and returns a L<List> of the results. If no such method was found, an empty
650-
L<List> is returned.
664+
C<$foo.*meth> walks the MRO and calls all the methods called C<meth> and submethods called C<meth> if the type is the same as type of C<$foo>.
665+
Those methods might be multies, in which case the matching candidate
666+
would be called.
651667
652-
Technically, not a real operator; it's syntax special-cased in the compiler.
668+
After that, a L<List> of the results are returned. If no such method was found,
669+
an empty L<List> is returned.
670+
671+
Technically, postfix C<.+> calls C<.*> at first. Read postfix C<.+> section to
672+
see examples.
653673
654674
X<|postfix ».>X«|postfix >>.»
655675
=head2 postfix C<».> / postfix C«>>.»

0 commit comments

Comments
 (0)