Skip to content

Instantly share code, notes, and snippets.

@fernandezpablo85
Created October 22, 2011 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fernandezpablo85/1306630 to your computer and use it in GitHub Desktop.
Save fernandezpablo85/1306630 to your computer and use it in GitHub Desktop.
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