Inspectopedia Help

Iterated elements are not used in forEach

Reports forEach loops that do not use iterable values.

Example:

listOf(1, 2, 3).forEach { }

The quick fix introduces anonymous parameter in the forEach section:

listOf(1, 2, 3).forEach { _ -> }

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3

Plugin:

Kotlin, @snapshot@

Last modified: 13 July 2023