if statements with three or more branches that can be replaced with the when expression with a subject.
Example:
fun translateNumber(n: Int): String {
return if (n == 1) {
"one"
} else if (n == 2) {
"two"
} else {
"???"
}
}
The quick-fix converts the if expression to when:
fun translateNumber(n: Int): String {
return when (n) {
1 -> {
"one"
}
2 -> {
"two"
}
else -> {
"???"
}
}
}