Course of Raku / Functional, concurrent, reactive, and web programming / Concurrent programming / Channels / Sending and receiving
Quiz — Channels
What does the following program print?
my $c = Channel.new;
$c.send(10);
$c.send(20);
say $c.receive;| 1 | 10 |
| 0 | 20 |
| 0 | 30 |
| 0 | (10 20) |
A channel is a first-in, first-out queue. 10 was sent
first, so the first .receive returns 10.