Course of Raku / Functional, concurrent, reactive, and web programming / Concurrent programming / Promises / Exercises / Kept or broken

Solution: Kept or broken

Here is a possible solution to the task.

Code

my $p = start { 10 };
await $p;
say $p.status;

🦋 You can find the source code in the file kept-or-broken.raku.

Output

Kept

Comments

  1. After the block finishes successfully, the promise is kept.

  2. .status reports this as Kept. Had the block thrown an exception, the status would be Broken instead.

Course navigation

Kept or broken   |   Channels