Skip to content

Instantly share code, notes, and snippets.

@timruffles
Created November 28, 2011 21:18
Show Gist options
  • Select an option

  • Save timruffles/1402117 to your computer and use it in GitHub Desktop.

Select an option

Save timruffles/1402117 to your computer and use it in GitHub Desktop.
bank account closure demo
BankAccount = (balance = 0) ->
(cmd, amount = 0) ->
if cmd == "withdraw" then BankAccount balance - amount
else if cmd == "deposit" then BankAccount balance + amount
else if cmd == "balance" then balance.toFixed 2
else "What kind of person would try to #{cmd} a bank account?"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment