'when' has only 'else' branch and can be simplified
Reports when
expressions with only an else
branch that can be simplified.
Simplify expression quick-fix can be used to amend the code automatically.
Example:
fun redundant() {
val x = when { // <== redundant, the quick-fix simplifies the when expression to "val x = 1"
else -> 1
}
}
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Kotlin, @snapshot@ |
Last modified: 13 July 2023