Created
January 10, 2012 22:47
-
-
Save maleficarum/1591685 to your computer and use it in GitHub Desktop.
Ternary operator implementation for scala
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
case class Bool(b: Boolean) { | |
def ?[X](t: => X) = new { | |
def |(f: => X) = if(b) t else f | |
} | |
} | |
object Bool { | |
implicit def BooleanBool(b: Boolean) = Bool(b) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment