Back to Intellij Community

GroovyMapPutCanBeKeyedAccess

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

2025.3-rc-2345 B
Original Source

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

Example:

def map = ["foo": "bar"]
map.put("foo", "baz") // map.put("foo", "baz") could be replaced with map["foo"] = "baz"

After the quick-fix is applied:

def map = ["foo": "bar"]
map["foo"] = "baz"