When I learned about Kotlin a few years ago, I was surprised to find that I couldn’t write a ? b : c, which is common in many other languages. Of course, I can use if (a) b else c instead, but it’s not neat.
After using Kotlin for a few years, I still think that the ternary operator should be supported. It’s the only obvious disadvantage I can think of (compared to Java).
I noticed this post, but it’s closed. Hope the ternery operator can be reconsidered.
I do like the C-based conditional ternary operator. But, there are actually more languages that do not support it - such as some recent ones (eg. Rust, Julia, Nim and Crystal) and older popular ones like Python and Lua. Scala which inspired some aspects of Kotlin also chose not to implement it either.
Yeah, I generally only use it for things that are not computed. Most often for choosing between 2 string resources for the UI based on a boolean such as this other function I have:
val Boolean.toYesNo: StringDesc get() = map(yes_label, no_label)