Errata for Modern Concurrency in Swift 1st Edition

Fixed, thank you Audrey

Also, fixed - whether to call finish() here or not was a tough call, but I think it’s better not to.

1 Like

so you can also remove the return :wink:

Yes, definitely :slight_smile: Thanks Audrey

In Chapter 4, Section 2, Subsection Simplifying async sequences with AsyncStream, the first initializer in the list of initializers seems to have odd formatting due to Swifts unlabelled parameters:

init(_:bufferingPolicy:_:) is rendered as init(:bufferingPolicy::): because the (I’m guessing here) _ is treated as a markdown indicator and not an unlabeled marker.

Either the first code block or the last code block in Chapter 4, Section 3, Subsection _ Stopping the timer and sending the message_ is incorrect:

If the first is incorrect, then it should be

guard countdown > 0 else {
  timer.invalidate()
  continuation.yield("🎉 " + message)
-  continuation.finish()
  return
}

If the last code block is incorrect, the it should be

let counter = AsyncStream<String> { continuation in
  var countdown = 3
  Timer.scheduledTimer(
    withTimeInterval: 1.0,
    repeats: true
  ) { timer in
    guard countdown > 0 else {
      timer.invalidate()
      continuation.yield(with: .success("🎉 " + message))
+     continuation.finish()
      return
    }

    continuation.yield("\(countdown) ...")
    countdown -= 1
  }
}

(I’m not sure which is correct but the final project says the finish call is not needed)

I’m working on the " Simplifying async sequences with AsyncStream" in chapter 4.
I’m using Xcode 14.1 beta 2

for the typewrite example using AsyncStream I get the following errors in a playground…

Main actor-isolated var 'index' can not be mutated from a non-isolated context
Main actor-isolated var 'phrase' can not be referenced from a non-isolated context

The code was cut-and-pasted right from the web site, so I didn’t introduce a type-o. Any ideas?