Condition and switches
Kotlin conditions and switches
Conditions
Ternary operator approach
Kotlin doesn’t have a specific ternary operator like you would see in other languages, but it does allow you to use conditions within a variable assignment. This can mimic the behavior of a ternary.
Kotlin ternary example:
val myValue = if(cond)
"my value"
else "my other value"
Next: Static Blocks