Example of sendable

Asked on 08/04/2024

1 search

An example of a sendable type in Swift can be found in the session "Migrate your app to Swift 6." In this session, the concept of sendable types is discussed in the context of ensuring data-race safety when working with concurrency.

Here's a specific example:

struct Drink: Sendable {
    let name: String
    let size: Int
}

In this example, Drink is a struct with immutable properties, making it safe to be shared between different concurrency domains. By marking it as Sendable, you ensure that it can be safely sent between actors without risking data races.

For more details, you can refer to the session Migrate your app to Swift 6 (32:27).