Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardSwiftSendable and data-race safetySingle-choice MCQ

Why does the compiler reject capturing a non-Sendable class instance in a closure passed to `Task.detached`, even when the surrounding code is single-threaded at the moment of capture?

final class Box { var n = 0 } let b = Box() Task.detached { b.n += 1 } // error