The following
class Bank {
static var coinsInBank = 10_000
static func distribute(coins numberOfCoinsRequested: Int) -> Int {
let numberOfCoinsToVend = min(numberOfCoinsRequested, coinsInBank)
coinsInBank -= numberOfCoinsToVend
return numberOfCoinsToVend
}
static func receive(coins: Int) {
coinsInBank += coins
}
}
no longer compiles and fails with error: static property 'coinsInBank' is not concurrency-safe because it is nonisolated global shared mutable state compilation error.
PS: It would be nice to correct this phrasing as well:
A deinitializer is called immediately before a class instance is deallocated. You write deinitializers with the
deinitkeyword, similar to how initializers are written with theinitkeyword. Deinitializers are only available on class types.
since deinitializers available for ~Copyable as well (in general, it would be better if copyable and related features were discusssed in the language guide and not only in the language reference part, but at least a link to ~Copyable should be given here).