Created
September 19, 2012 03:19
-
-
Save YusukeKokubo/3747461 to your computer and use it in GitHub Desktop.
Operator ||| like as ||
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 CondOp(val a: Boolean) { | |
def |||(b: => Boolean) = if (a) a else b | |
} | |
object Main { | |
def main(args: Array[String]) { | |
implicit def boolWrapper(cond: Boolean) = new CondOp(cond) | |
true ||| { println("hoge"); false } | |
false ||| { println("foo"); true} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
lean to scala in "by-name-parameters".