-
-
Save mpilquist/4370310 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
class Age private (val v: Short) extends AnyVal { | |
def isInfant = v < 2 | |
def isToddler = v >= 2 && v <= 4 | |
def isSenior = v >= 50 | |
} | |
object Age { | |
def apply(v: Short): Age = { | |
require(v >= 0 && v < 200, "Must be between 0 and 200") | |
new Age(v) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment