Created
September 24, 2012 22:28
-
-
Save Mahoney/3778843 to your computer and use it in GitHub Desktop.
Boolean Logic in Pure Scala - 2nd cut
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 abstract class Boolean { | |
... | |
def &&(other: => Boolean): Boolean | |
def ||(other: => Boolean): Boolean | |
... | |
} | |
case object true1 extends Boolean { | |
... | |
override def &&(other: => Boolean): Boolean = other | |
override def ||(other: => Boolean): Boolean = this | |
... | |
} | |
case object false1 extends Boolean { | |
... | |
override def &&(other: => Boolean): Boolean = this | |
override def ||(other: => Boolean): Boolean = other | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment