Skip to content

Instantly share code, notes, and snippets.

@tomer-ben-david
Created April 1, 2014 10:41
Show Gist options
  • Save tomer-ben-david/9911660 to your computer and use it in GitHub Desktop.
Save tomer-ben-david/9911660 to your computer and use it in GitHub Desktop.
"Enum" Scala way
sealed trait Currency { def name: String }
case object EUR extends Currency { val name = "EUR" } //etc.
case class UnknownCurrency(name: String) extends Currency
So now I have the advantage of...
trade.ccy match {
case EUR =>
case UnknownCurrency(code) =>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment