Inspectopedia Help

Ternary expression can be replaced with safe call

Reports ternary expressions which can be replaced by a safe call.


def charArray(String s) { s == null ? null : s.toCharArray() }

After the quick-fix is applied:

def charArray(String s) { s?.toCharArray() }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3


Groovy, 233.SNAPSHOT

Last modified: 13 July 2023