Associative array/Iteration: Difference between revisions

Content added Content deleted
m (Undo revision 235061 by Petelomax (talk) (oops))
(Kotlin: with block idiom)
Line 1,406: Line 1,406:
val map = mapOf("hello" to 1, "world" to 2, "!" to 3)
val map = mapOf("hello" to 1, "world" to 2, "!" to 3)


with(map) {
map.forEach { println("key = ${it.key}, value = ${it.value}") }
map.keys.forEach { println("key = $it") }
forEach { println("key = ${it.key}, value = ${it.value}") }
map.values.forEach { println("value = $it") }
keys.forEach { println("key = $it") }
values.forEach { println("value = $it") }
}
}</lang>
}</lang>
{{Out}}
{{Out}}