Course of Raku / Functional, concurrent, reactive, and web programming / Reactive programming / await / Exercises / Await a promise

Solution: Await a promise

Here is a possible solution to the task.

Code

my $p = start { 100 };
say await $p;

🦋 You can find the source code in the file await-a-promise.raku.

Output

100

Comments

  1. start launches the work and returns a promise.

  2. await waits for it and yields the result, 100.

Course navigation

Await a promise   |   Await a supply