Inspectopedia Help

Call to Map.put can be keyed access

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


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"

Inspection Details

By default bundled with:

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin:

Groovy, 241.16690

Last modified: 29 April 2024