RosettaCodeData/Task/Associative-array-Iteration/Julia/associative-array-iteration...

20 lines
354 B
Plaintext

dict = Dict("hello" => 13, "world" => 31, "!" => 71)
# applying a function to key-value pairs:
foreach(println, dict)
# iterating over key-value pairs:
for (key, value) in dict
println("dict[$key] = $value")
end
# iterating over keys:
for key in keys(dict)
@show key
end
# iterating over values:
for value in values(dict)
@show value
end