Search code examples
kotlinboolean-expression

Kotlin Simplify Boolean Expression


Why do I get a minor error that says "Simplify boolean expression" in my if condition line?

For instance this snippet of code:

if (isClear==true){
    displayText.setText("")
}

Solution

  • Try the following to simply the Boolean expression and avoid the error:

    if (isClear) {
        displayText.setText("")
    }