Course of Raku / Advanced / Control flow / Phasers / Exercises / The order of ENDs

Solution: The order of ENDs

Here is a possible solution to the task.

Code

END say 'first END';
END say 'second END';

say 'body';

🦋 You can find the source code in the file end-order.raku.

Output

body
second END
first END

Comments

  1. Both END phasers run after the main code, so body is printed first.

  2. Multiple END phasers run last-in, first-out: the second END, declared later, runs before the first END. This mirrors how clean-up usually has to undo the most recent setup first.

Course navigation

The order of ENDs   |   Quiz — Phasers