Back to Intellij Community

GroovyListSetCanBeKeyedAccess

plugins/groovy/groovy-psi/resources/inspectionDescriptions/GroovyListSetCanBeKeyedAccess.html

2025.3-rc-2322 B
Original Source

Reports calls to java.util.List.set() methods. Such calls could be replaced by the shorter and clearer keyed access form.

Example:

def list = ["foo"]
list.set(0, "bar") // list.set(0, "bar") could be replaced with list[0] = "bar"

After the quick-fix is applied:

def list = ["foo"]
list[0] = "bar"