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

Await a promise

Problem

Start three promises: one that sleeps 0.3 seconds and produces the string 'slow', one that sleeps 0.1 and produces 'quick', and one that sleeps 0.2 and produces 'medium'. Await them all as a list and print the results. Note what order they come back in: the quick job finishes first, but does that change the output?

Example

The program prints:

(slow quick medium)

Solution

See the solution

Course navigation

Waiting for completion   |   Solution: Await a promise