Associative array/Iteration: Difference between revisions

Content added Content deleted
m (→‎{{header|Sidef}}: simplified code)
(→‎Kotlin: Shortened the code for better readability)
Line 2,017: Line 2,017:


=={{header|Kotlin}}==
=={{header|Kotlin}}==
<syntaxhighlight lang="scala">fun main(a: Array<String>) {
<syntaxhighlight lang="scala">fun main() {
val map = mapOf("hello" to 1, "world" to 2, "!" to 3)
val map = mapOf("hello" to 1, "world" to 2, "!" to 3)


with(map) {
with(map) {
entries.forEach { println("key = ${it.key}, value = ${it.value}") }
forEach { println("key = ${it.key}, value = ${it.value}") }
keys.forEach { println("key = $it") }
keys.forEach { println("key = $it") }
values.forEach { println("value = $it") }
values.forEach { println("value = $it") }