Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Created June 15, 2017 06:55
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 anonymous/fe3eee59b3e63b140fdb1434c046c36e to your computer and use it in GitHub Desktop.
Save anonymous/fe3eee59b3e63b140fdb1434c046c36e to your computer and use it in GitHub Desktop.
the description for this gist
case class Percent private (value: Int) {
require(value >= 0)
require(value <= 100)
}
object Percent {
def fromInt(input: Int): Option[Percent] =
if(input >= 0 && input <= 100) {
Some(Percent(input))
} else {
None
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment