Back to Intellij Community

SimplifyWhenWithBooleanConstantCondition

plugins/kotlin/code-insight/descriptions/resources-en/inspectionDescriptions/SimplifyWhenWithBooleanConstantCondition.html

2025.3-rc-2360 B
Original Source

Reports when expressions with the constant true or false branches.

Simplify "when" quick-fix can be used to amend the code automatically.

Examples:

fun redundant() {
      when { // <== redundant, quick-fix simplifies the when expression to "println("true")"
          true -> println("true")
          else -> println("false")
      }
  }