Skip to content

Instantly share code, notes, and snippets.

@MinCha
Created September 11, 2015 06:59
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 MinCha/f0ed0ef62c8b2b0a4db3 to your computer and use it in GitHub Desktop.
Save MinCha/f0ed0ef62c8b2b0a4db3 to your computer and use it in GitHub Desktop.
Scala Unary
sealed abstract class AdviceGrade {
def unary_!(): AdviceGrade
}
case object VeryGood extends AdviceGrade {
override def unary_!(): AdviceGrade = Bad
}
case object Good extends AdviceGrade {
override def unary_!(): AdviceGrade = Good
}
case object Bad extends AdviceGrade {
override def unary_!(): AdviceGrade = VeryGood
}
!Bad -> VeryGood
!Good -> Good
!VeryGood -> Bad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment