Chapter 2: Hello Future

In the “Hello Future” the output should be:

——— Example of: Future ———
Original
2
finished
Second 2
Second finished

However, I get this output:

——— Example of: Future ———
Original
Second 2
Second finished
2
finished

I’ve tried the code from the “Final.playground” as well and I see the same result. Do I do something wrong or is it okay to have the wrong order?

I don’t have that particular book / source available at the moment. I’m going to take a guess and bring up 2 potential things:

  1. Your version of Swift probably is newer than the one in the book, behaviors may slight change, because (2)
  2. Asynchronous code isn’t guaranteed to have a particular order of completion, the whole point of Future/Combine/Await is to create points where a completion connects to the next step.

I’ll take a calculated risk at saying that this should be ok.

1 Like