Reputation: 10290
It seems like with the latest Kotlin update you can no longer iterate through maps with destructured Entry
. For example:
val map = HashMap<Int, String>()
for ((i, s) in map) { // compiler error here
... // code
}
The compiler error is For-loop range must have an iterator() method
This feature previously worked as expected, iterating through each entry in the map. I have also tried to use map.entries
and map.entrySet()
(deprecated) and with these:
What is the idiomatic way to iterate through a map now? Is this a bug?
Upvotes: 4
Views: 3286
Reputation: 148109
Looks like a bug in IDE and Gradle plugins. I tried the following:
No following changes could let me reproduce the bug in this project, but I could in a new one.
Upvotes: 1
Reputation: 10290
Oddly IntelliJ offered me to "update" to Kotlin plugin 2428 which caused this.
Downloading off JetBrain's plugin repository (Kotlin plugin here: http://plugins.jetbrains.com/plugin/6954?pr=idea) and choosing Install from disk...
in IntelliJ fixed the problem.
Upvotes: 0