Skip to content

Instantly share code, notes, and snippets.

@Jire
Created January 24, 2016 10:58
Show Gist options
  • Save Jire/46b1ee35855a5e97bfd5 to your computer and use it in GitHub Desktop.
Save Jire/46b1ee35855a5e97bfd5 to your computer and use it in GitHub Desktop.
class Ternary<T>(val condition: Boolean, val whenTrue: T) {
operator fun minus(whenFalse: T) = if (condition) whenTrue else whenFalse
}
operator fun <T> Boolean.plus(whenTrue: T) = Ternary(this, whenTrue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment