Back to Intellij Community

NullableBooleanElvis

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

2025.3-rc-2314 B
Original Source

Reports cases when an equality check should be used instead of the elvis operator.

Example:

fun check(a: Boolean? = null) {
    if (a ?: false) throw IllegalStateException()
}

After the quick-fix is applied:

fun check(a: Boolean? = null) {
    if (a == true) throw IllegalStateException()
}