Skip to content

Instantly share code, notes, and snippets.

@SUPERCILEX
Created August 15, 2018 18:43
Show Gist options
  • Save SUPERCILEX/9fb0f9354ffa0685caab2bb4843f1b06 to your computer and use it in GitHub Desktop.
Save SUPERCILEX/9fb0f9354ffa0685caab2bb4843f1b06 to your computer and use it in GitHub Desktop.
infix fun <T> Boolean.q(primary: T) = if (this) Ternary(primary) else null
infix fun <T> Ternary<T>?.e(other: T) = if (this == null) other else result
data class Ternary<T>(internal val result: T)
val bool = true
println(bool q "true" e "false")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment