Course of Raku / Advanced / Control flow / Phasers / Exercises / Final message
Solution: Final message
Here is a possible solution to the task.
Code
my $count = 0;
END say "processed $count items";
$count++ for 1..3;🦋 You can find the source code in the file final-message.raku.
Output
processed 3 itemsComments
The
ENDphaser is written before the loop, but it runs last — after the main code has finished. By then$counthas been incremented three times.Because the phaser closes over
$count, it reads the variable’s final value, not the0it held when the phaser appeared in the source. This is the usual reason to put a summary inEND.
Course navigation
← Final message | Begin first →