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;
030
160
00
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.

Course navigation

Tapping a supply   |   Transforming a supply