Skip to content

Instantly share code, notes, and snippets.

@michaeldiamant
Created October 7, 2012 21:31
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 michaeldiamant/3849665 to your computer and use it in GitHub Desktop.
Save michaeldiamant/3849665 to your computer and use it in GitHub Desktop.
Represent a price with a case class
case class UsdPrice(value: BigDecimal) {
def +(p: UsdPrice) = UsdPrice(value + p.value)
def -(p: UsdPrice) = UsdPrice(value - p.value)
}
case class EurPrice(value: BigDecimal) {
def +(p: EurPrice) = EurPrice(value + p.value)
def -(p: EurPrice) = EurPrice(value - p.value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment