An if expression lets Scala choose between branches.

Conditionals

Conditionals.scala
object Main {
  def main(args: Array[String]): Unit = {
    val temperature = 
    val status = if (temperature >= 80) {
      "warm"
    } else {
      "comfortable"
    }

    println("temperature=" + temperature)
    println("status=" + status)
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val temperature = 
    val status = if (temperature >= 80) {
      "warm"
    } else {
      "comfortable"
    }

    println("temperature=" + temperature)
    println("status=" + status)
  }
}
object Main {
  def main(args: Array[String]): Unit = {
    val temperature = 
    val status = if (temperature >= 80) {
      "warm"
    } else {
      "comfortable"
    }

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