Cómo iterar sobre HashMap en Kotlin?
typealias HashMap<K, V> = HashMap<K, V> (source)
kotlin
kotlin-extension
Nomi
fuente
fuente

map.forEach { (key, value) -> println("$key = $value") }{ (key, value) -> ... }. Ken Zira tiene más información en su respuesta.Para la respuesta anterior, ¡tenga cuidado con la
AndroidsiguienteN!map.forEach { key, value -> println("$key = $value") }referencia a
Java 8api que conduce a:Rejecting re-init on previously-failed class java.lang.Class<T>map.forEach { (key, value) -> println("$key = $value") }es
Kotlincaracterísticafuente
Otra forma que no se ha mencionado es:
val mapOfItems = hashMapOf(1 to "x", 2 to "y", -1 to "zz") mapOfItems.map { (key, value) -> println("$key = $value") }fuente