DevPrep

All topics › Swift Concurrency (async/await, actors)

What is Sendable and why is it needed?

Senior PRO

The essence

Sendable is a marker protocol with no requirements: "a value of this type can be safely passed across an isolation boundary (between actors, tasks, threads) without data races". The compiler checks it at every boundary: arguments and results of actor calls, captures in Task { }, @Sendable closures. In Swift 6 a violation is a compile error; in Swift 5 with -strict-concurrency=complete it is a warning.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store