Inspectopedia Help

Equality check can be used instead of elvis for nullable boolean check

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


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() }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3


Kotlin, @snapshot@

Last modified: 13 July 2023