Skip to content

Commit

Permalink
Document sigiled method calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaiepi committed Apr 1, 2020
1 parent 6d5adef commit 7a4f43b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions doc/Language/objects.pod6
Expand Up @@ -319,6 +319,30 @@ separated by a colon, the arguments: C<method invocant: arguments>. We can use
this syntax whenever it feels more natural than the classical
period-and-parentheses one. It works exactly in the same way.
Note how the call to the C<notes> method in the C<Str> method is made on
C<self>. Writing method calls this way will leave the return value of
the method as is with regards to containers. To containerize return
values, you can make method calls on a sigil instead of C<self>. This
calls various methods on the return value of the method depending on the
sigil used to containerize it:
=begin table
Sigil | Method
==============
$ | item
@ | list
% | hash
& | item
=end table
For example, the C<Str> method of C<Journey> can be rewritten not to use
the C<~> operator by embedding a sigiled method call in the string it
returns:
=begin code :skip-test<demonstrates another way of writing a method>
method Str { ⤷ $!origin\n$ⲧ$.notes()$!destination ⤶\n" }
=end code
Method names can be resolved at runtime with the C<.""> operator.
=begin code
Expand Down

0 comments on commit 7a4f43b

Please sign in to comment.