Values from Dictionary

hi,
I have the following dictionary called “states”:

states=Dict{Any,Any}((0, 0) => Array{Any,1}[[[0], (0, 0), Any[0, 0]], [[1], (1, 0), Any[1, 1]]],(1, 0) => Array{Any,1}[[[0], (0, 1), Any[1, 0]], [[1], (1, 1), Any[0, 1]]],(0, 1) => Array{Any,1}[[[0], (0, 0), Any[1, 1]], [[1], (1, 0), Any[0, 0]]],(1, 1) => Array{Any,1}[[[0], (0, 1), Any[0, 1]], [[1], (1, 1), Any[1, 0]]])

and I want to take the values of states and define them as “val_0” and “val_1” so that I get the following output:

val_0=[[0], (0, 0), Any[0, 0]] 
val_1=[[1], (1, 0), Any[1, 1]]

(so val_0 and val_1 are from (0, 0) => …).

(In the next step val_0 shall be:
val_0=[[0], (0, 1), Any[1, 0]]
val_1= [[1], (1, 1), Any[0, 1]]
from key (1, 0) and so on).

Hey @ar12y

Is this what you want?

for v in values(states)
       val_0, val_1 = v
       # do something
end
2 Likes

@ar12y, I think you want:

for (val_0, val_1) in values(states)
    println(val_0)
    println(val_1)
    println()
end

Hope this helps.

1 Like

@findmyway , @tro3

this is exactly the solution I was looking for.
Thank you for your replies.