Course of Raku / Functional, concurrent, reactive, and web programming / Concurrent programming / Channels / Exercises / Drain a channel
Solution: Drain a channel
Here is a possible solution to the task.
Code
my $c = Channel.new;
$c.send('a');
$c.send('b');
$c.close;
say $c.list.join(',');🦋 You can find the source code in the file drain-channel.raku.
Output
a,bComments
.listdrains every value left in the closed channel, in order..join(',')glues the two strings together with a comma between them.