So let me reform this question:
I have two hashes I’m comparing against. At some point in my code I get a response such as..
@moves = {:wm01 => {:a1=>"O", :a2=>" ", :a3=>" ", :b1=>" ", :b2=>"O", :b3=>" ", :c1=>" ", :c2=>" ", :c3=>" "}
This corresponds to an answer key hash…
@anskey={
:wm01=>":c3",:wm02=>":c2",:wm03=>":c1",:wm04=>":b3",:wm05=>":b1",:wm06=>":a3",:wm07=>":a2",:wm08=>":a1",
:wm09=>":a3",:wm10=>":c1",:wm11=>":a1",:wm12=>":c3",:wm13=>":c3",:wm14=>":c1",:wm15=>":c3",:wm16=>":a1",
:wm17=>":b1",:wm18=>":b2",:wm19=>":b3",:wm20=>":a2",:wm21=>":b2",:wm22=>":b2",:wm23=>":c2",:wm24=>":b2"
}
in this case I need to iterate @anskey where @moves.keys == @anskey.keys
(hmmm. I may have just answered my own question)
and then set….
my_answer_is = @anskey.value
Hope this is clearer.
Original “question” below:
It’s been a long day and I’m getting screen fatigue…
I have this…
str = [:wm24]
want to say…
@anskey[:wm24]
this is wrong..
@anskey[str]
what is right?
@anskey[?]
You can pass it the first element from the array like this:
Or if you want to access an element based on its index (position in the array), you count up from zero. So in this case: