Last active
February 4, 2022 13:36
-
-
Save SebastianBoldt/93fba63eb7a4a78a83aee65b8c8c344d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
actor BankAccount { | |
private var balance: Int = 0 | |
let accountHolder: String? // 3. | |
init(accountHolder: String) { | |
self.accountHolder = accountHolder // 2. | |
} | |
func logBalance() { | |
print(balance) // Accessing Balance without await | |
} | |
} | |
let bankAccount = BankAccount(accountHolder: "Sebastian Boldt") | |
Task { | |
await bankAccount.logBalance() // 1. | |
print(bankAccount.accountHolder ?? "No account associated") // 3. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment