Skip to content

Commit 14b4816

Browse files
author
Jan-Olof Hendig
committed
Added a few code examples
1 parent 23e55ac commit 14b4816

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

doc/Type/Supply.pod6

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,27 +169,39 @@ since the C<list> call.
169169
170170
=head2 method grab
171171
172-
method grab(Supply:D: &process --> Supply:D)
172+
method grab(Supply:D: &when-done --> Supply:D)
173173
174-
Waits until the given supply is done. It will then call the given process
175-
closure passing all of the values seen, Then creates a supply to which all
176-
values returned from the process closure.
174+
Waits until the given C<Supply> is done. It will then call the C<&when-done>
175+
closure passing all of the values seen, Then creates a C<Supply> to which all
176+
values returned from the C<&when-done> closure are emitted.
177+
178+
my $s = Supply.from-list(4, 10, 3, 2);
179+
my $t = $s.grab(&sum);
180+
$t.tap(&say); # OUTPUT: «19␤»
177181
178182
=head2 method reverse
179183
180184
method reverse(Supply:D: --> Supply:D)
181185
182-
Waits until the given supply is done, then creates a supply to which all
186+
Waits until the given C<Supply> is done, then creates a C<Supply> to which all
183187
values seen are emitted in reverse order.
184188
189+
my $s = Supply.from-list(1, 2, 3);
190+
my $t = $s.reverse;
191+
$t.tap(&say); # OUTPUT: «3␤2␤1␤»
192+
185193
=head2 method sort
186194
187195
method sort(Supply:D: &by? --> Supply:D)
188196
189-
Waits until the given supply is done, then creates a supply to which all
197+
Waits until the given C<Supply> is done, then creates a C<Supply> to which all
190198
values seen are emitted in sorted order. Optionally accepts a comparator
191199
L<Block|/type/Block>.
192200
201+
my $s = Supply.from-list(4, 10, 3, 2);
202+
my $t = $s.sort();
203+
$t.tap(&say); # OUTPUT: «2␤3␤4␤10␤»
204+
193205
=head1 Methods that return another Supply
194206
195207
=head2 method from-list

0 commit comments

Comments
 (0)