Skip to content

Commit b18bddb

Browse files
committed
Adds @zoffix's example to sink context
1 parent 1d80fac commit b18bddb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

doc/Language/contexts.pod6

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ You can force that sink context on L<Iterator>s, by using the L<C<sink-all>|/rou
1919
2020
In general, blocks will warn if evaluated in sink context; however, L<gather/take blocks|/language/control#Flow%29_gather_take> are explicitly evaluated in sink context, with values returned explicitly using C<take>.
2121
22+
In sink context, an object will call its `sink` method if present:
23+
24+
=begin code
25+
sub foo {
26+
return [<a b c>] does role {
27+
method sink { say "sink called" }
28+
}
29+
}
30+
foo
31+
# OUTPUT: sink called
32+
=end code
33+
34+
2235
=head1 Number X<|number context>
2336
2437
This context, and probably all of them except sink above, are I<conversion> or I<interpretation> contexts in the sense that they take an untyped or typed variable and duck-type it to whatever is needed to perform the operation. In some cases that will imply a conversion (from L<Str> to L<Int>, for instance); in other cases simply an interpretation (L<IntStr> will be interpreted as L<Int> or as L<Str>).

0 commit comments

Comments
 (0)