Course of Raku / Functional, concurrent, reactive, and web programming / Reactive programming / Supplies / Tapping a supply
Quiz — Supplies
What does the following program print?
my $total = 0;
Supply.from-list(10, 20, 30).tap(-> $v { $total += $v });
say $total;| 0 | 30 |
| 1 | 60 |
| 0 | 0 |
| 0 | [10 20 30] |
The tap runs for every value the supply emits, adding each to
$total. The sum of 10, 20, 30 is
60.