the.bay.news

Capturing functions vs casting functions

Swift Forums
Capturing functions vs casting functions
Thanks to SE-0434, it is possible to capture non-sendable function in an actor-isolated (and thus sendable) closure if it is isolated to the current context. If closure does nothing but calling the captured function, then this is effectively casting. But direct casting is not allowed. Even through pretty much the same logic applies here. @MainActor func test(completion: @escaping () -> Void) { let a: @MainActor () -> Void = { completion() } // ok let b: @MainActor () -> Void = complet...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.