Kotlin - Control Flow as Expressions
What is the problem with this Kotlin code?
val grade = if (score >= 90) "A"
val grade = if (score >= 90) "A"
if expressionif expression lacks an else branch, which is mandatory when used as an expression.else, the compiler cannot determine the value for cases when the condition is false.else branch causes a compilation error -> Option Bif expressions have else [OK]15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions