Skip to content

Instantly share code, notes, and snippets.

@fernandezpablo85
Created October 22, 2011 23:26
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/1306626 to your computer and use it in GitHub Desktop.
Save fernandezpablo85/1306626 to your computer and use it in GitHub Desktop.
class Ternary (condition : Boolean, good : String)
{
def this(condition : Boolean) = this (condition, null)
def yes (good: String) = new Ternary(condition, good)
def no (bad : String) = if (condition) good else bad
}
val loggedIn = false
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