Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jacobsapps/3a6c1dd04555aacd6a09436661d2a993 to your computer and use it in GitHub Desktop.
Save jacobsapps/3a6c1dd04555aacd6a09436661d2a993 to your computer and use it in GitHub Desktop.
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