Last active
July 9, 2021 07:35
-
-
Save trevorhackman/d706fa832eb92c8e1f941f245af63a8f to your computer and use it in GitHub Desktop.
Kotlin Ternary Operator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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