my first infix (read: what could possibly go wrong...
# getting-started
j
my first infix (read: what could possibly go wrong)
Copy code
inline fun <reified T> Boolean.either(t: T): Pair<Boolean, T> = Pair(this, t)

inline infix fun <reified T> Pair<Boolean, T>.or(t: T): T = if (first) second else t 

var a = trueOrFalse.either(0) or 1