Skip to content

Instantly share code, notes, and snippets.

@justinhj
Created January 19, 2020 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinhj/ca4e24cc329bba8d12c050eeb1c64e69 to your computer and use it in GitHub Desktop.
Save justinhj/ca4e24cc329bba8d12c050eeb1c64e69 to your computer and use it in GitHub Desktop.
def eventToState(event: BankAccountEvent): AccountState = {
event match {
case DepositEvt(time, amount) =>
AccountState(amount, None)
case PurchaseEvt(time, amount) =>
AccountState(-amount, None)
case AssignAccountHolderEvt(time, accountHolder) =>
AccountState(0, accountHolder.some)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment