Created
July 4, 2025 13:47
-
-
Save jacobsapps/3a6c1dd04555aacd6a09436661d2a993 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { | |
// ... | |
} | |
let account = BankAccount() | |
await account.deposit(1000) | |
// simultaneously attempt to withdraw | |
async let one = account.withdraw(500) | |
async let two = account.withdraw(500) | |
async let three = account.withdraw(500) | |
try await (one, two, three) | |
// throws .insufficientFunds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment