O'Reilly logo
  • Guangjia Gao thinks this is interesting:

val hour = 10 val greeting: String if (hour < 18) { greeting = "Good day" } else { greeting = "Good evening" }

From

Cover of Android Development with Kotlin

Note

val hour = 10
var greeting: String //this should be var, not val
if (hour < 18) {
greeting = "Good day"
} else {
greeting = "Good evening"
}
println(greeting)