Inspectopedia Help

'map.put()' can be converted to assignment

Reports map.put function calls that can be replaced with indexing operator ([]).

Using syntactic sugar makes your code simpler.

The quick-fix replaces put call with the assignment.

Example:

fun foo(map: MutableMap<Int, String>) { map.put(42, "foo") }

After the quick-fix is applied:

fun foo(map: MutableMap<Int, String>) { map[42] = "foo" }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Kotlin, @snapshot@

Last modified: 13 July 2023