Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- val FEMALE = Sex("female", 1)
- val MALE = Sex("male", 2)
- case class Sex(name: String, number: Int) {
- def unapply(arg: Sex): Option[Int] = Some(arg.number)
- }
- def apply(number: Int) = number match {
- case FEMALE => FEMALE
- case MALE => MALE
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement