Created
October 22, 2011 23:41
-
-
Save fernandezpablo85/1306637 to your computer and use it in GitHub Desktop.
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 Ternary(condition : Boolean) | |
{ | |
class TernaryResultHandler[A](condition : Boolean, good : A) | |
{ | |
def | (bad : A) = if (condition) good else bad | |
} | |
def ? [A](good: A) = new TernaryResultHandler(condition, good) | |
} | |
val loggedIn = true | |
val message = new Ternary(loggedIn) ? "Welcome" | "Please log in first" | |
println(message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment