Skip to content

Instantly share code, notes, and snippets.

@trevorhackman
Last active July 9, 2021 07:35
Show Gist options
  • Save trevorhackman/d706fa832eb92c8e1f941f245af63a8f to your computer and use it in GitHub Desktop.
Save trevorhackman/d706fa832eb92c8e1f941f245af63a8f to your computer and use it in GitHub Desktop.
Kotlin Ternary Operator
inline infix fun <T> Boolean.T(trueOutput: T) = TernaryPart(this, trueOutput)
inline infix fun <T> TernaryPart<T>.F(falseOutput: T) = if (condition) trueOutput else falseOutput
class TernaryPart<T>(val condition: Boolean, val trueOutput: T)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment