Provide extension to get mutable iterator from the mutable map

#KT-18992 Fixed
This commit is contained in:
Ilya Gorbunov
2017-07-21 23:44:30 +03:00
parent e0dc7a27a0
commit f10ea03173
2 changed files with 13 additions and 2 deletions
@@ -97,6 +97,18 @@ class MapTest {
assertEquals("beverage,beer,location,Mells,name,James", list.joinToString(","))
}
@Test fun iterateAndMutate() {
val map = mutableMapOf("beverage" to "beer", "location" to "Mells", "name" to "James")
val it = map.iterator()
for (e in it) {
when (e.key) {
"beverage" -> e.setValue("juice")
"location" -> it.remove()
}
}
assertEquals(mapOf("beverage" to "juice", "name" to "James"), map)
}
@Test
fun onEach() {