Skip to content

Instantly share code, notes, and snippets.

@dwhitney
Created July 6, 2011 14:33
Show Gist options
  • Select an option

  • Save dwhitney/1067370 to your computer and use it in GitHub Desktop.

Select an option

Save dwhitney/1067370 to your computer and use it in GitHub Desktop.
atomic{ implicit t =>
var accounts = accountsRef()
val (from, to) = (accounts(fromNo), accounts(toNo))
if(from.balance > amount){
accounts = accounts + (to.accountNo -> to.credit(amount))
accounts = accounts + (from.accountNo -> from.debit(amount))
accountsRef() = accounts
applyTransferFees()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment