Inspectopedia Help

Ternary expression can be replaced with elvis expression

Reports ternary expressions which can be replaced by an elvis expression.


def notNull(o, defaultValue) { o != null ? o : defaultValue }

After the quick-fix is applied:

def notNull(o, defaultValue) { o ?: defaultValue }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3


Groovy, 233.SNAPSHOT

Last modified: 13 July 2023