Associative array/Iteration: Difference between revisions

Kotlin entry
(Kotlin entry)
Line 1,401:
{x+1}'d[]
2 3 4</lang>
 
=={{header|Kotlin}}==
<lang scala>fun main(a: Array<String>) {
val map = mapOf("hello" to 1, "world" to 2, "!" to 3)
 
map.forEach { println("key = ${it.key}, value = ${it.value}") }
map.keys.forEach { println("key = $it") }
map.values.forEach { println("value = $it") }
}</lang>
{{Out}}
<pre>key = hello, value = 1
key = world, value = 2
key = !, value = 3
key = hello
key = world
key = !
value = 1
value = 2
value = 3</pre>
 
=={{header|Lang5}}==
Anonymous user