You could define your own `Boolean` extension function that returns `null` when the `Boolean` is `false` to provide a structure similar to the ternary operator:
infix fun <T> Boolean.then(param: T): T? = if (this) param else null
This would make an `a ? b : c` expression translate to `a then b ?: c`, like so:
println(condition then "yes" ?: "no")
**Update:**
But to do some more Java-like conditional switch you will need something like that
```infix fun <T> Boolean.then(param: () -> T): T? = if (this) param() else null```
```println(condition then { "yes" } ?: "no")```
pay attention on the lambda. its content calculation should be postponed until we make sure `condition` is `true`
This one looks clumsy, [that is why there is high demanded request exist to port Java ternary operator into Kotlin](
[To see links please register here]
)