Inspectopedia Help

Local variable is reassigned in closure or anonymous class

Reports local variables assigned to expression with different type inside of closure or anonymous class.


int sum = 0 [1, 2, 3].each { sum += 'as' } println(sum)

As a result, the integer variable sum is reassigned to a String expression.

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3


Groovy, 233.SNAPSHOT

Last modified: 13 July 2023