Created
August 3, 2012 17:11
-
-
Save hamnis/3249635 to your computer and use it in GitHub Desktop.
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 Score { | |
def isEmpty = this match { | |
case SetScore(_, _) => false | |
case NoScore => true | |
} | |
def isDefined = !isEmpty | |
def toOption: Option[(Int, Int)] = this match { | |
case NoScore => None | |
case SetScore(home, away) => Some(home -> away) | |
} | |
} | |
case object NoScore extends Score | |
case class SetScore(home: Int, away: Int) extends Score |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment