Created
April 1, 2014 10:41
-
-
Save tomer-ben-david/9911660 to your computer and use it in GitHub Desktop.
"Enum" Scala way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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