Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardSwiftactors and actor isolationSingle-choice MCQ

What does this actor code do at runtime when `transfer` is called and why is the final balance potentially wrong despite `Account` being an actor?

actor Account { var balance: Int = 100 func deposit(_ x: Int) { balance += x } func transfer(_ x: Int, to other: Account) async { balance -= x await other.deposit(x) // more logic reading/writing self.balance here } }