An if expression lets Kotlin choose between branches.

Conditionals

Conditionals.kt
fun main() {
    val temperature = 
    val status = if (temperature >= 80) {
        "warm"
    } else {
        "comfortable"
    }

    println("temperature=$temperature")
    println("status=$status")
}
fun main() {
    val temperature = 
    val status = if (temperature >= 80) {
        "warm"
    } else {
        "comfortable"
    }

    println("temperature=$temperature")
    println("status=$status")
}
fun main() {
    val temperature = 
    val status = if (temperature >= 80) {
        "warm"
    } else {
        "comfortable"
    }

    println("temperature=$temperature")
    println("status=$status")
}
if expression Kotlin `if` can produce a value, so the chosen branch can be assigned to a variable.