No Ternary Operator :(


While programming with kotlin I wanted to use the ternary operator something like the following

condition ? true_result : false_result.

I couldn’t find it anywhere in the documentation, I went to the github repo and took a look to see if I could find the grammar for kotlin. Sure enough they have an expressions file. I took a look and unfortunately wasn’t able to find any indication of a ternary operator. I figured this might caused by the existing use of the null check operator ?

Unfortunately kotlin doesn’t have this in the language, the closest thing that is available is this:

val max = if (a > b) a else b

Not horrible but not great either.

Master Android Development with RxJava

Minirxjavacover

Get this FREE 7000+ word guide as a pdf, so that you can take it with you and read it on the go.


I'll teach you about RxJava so that you can:

  • Write better android apps
  • Handle concurrency easily
  • Take full advantage of useful Rx libraries
I'll even throw in an extra chapter on common mistakes, and how to avoid them.
We won't send you spam. Unsubscribe at any time. Powered by ConvertKit

Master Android Development with RxJava

Common rx java mistakesv2

Get this FREE 7000+ word guide as a pdf, so that you can take it with you and read it on the go.


I'll teach you about RxJava so that you can:

  • Write better android apps
  • Handle concurrency easily
  • Take full advantage of useful Rx libraries
I'll even throw in an extra chapter on common mistakes, and how to avoid them.
We won't send you spam. Unsubscribe at any time. Powered by ConvertKit

Leave a Reply

Your email address will not be published. Required fields are marked *