Akbar
09/04/2019, 2:48 PMLuke
09/04/2019, 2:56 PMif is an expression. You can do val a = if (condition) "something" else "something else". See https://kotlinlang.org/docs/reference/control-flow.htmlCasey Brooks
09/04/2019, 2:57 PMif statements are expressions in Kotlin (they return a result) and so can be used to do exactly the same thing as the ternary operator, but is less confusing.
a = b ? c : d
is the same as
a = if(b) c else dDALDEI
09/04/2019, 3:34 PMSam
09/04/2019, 4:50 PM?: works well as a shorthand ternary dealing with nulls.
a = nullableValue ?: nonnullDefaultValueAkbar
09/05/2019, 6:45 AM