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