I'm iterating through an array or hash, and I'd like to get values based on index.
@lv = {'apple' => ['round', 'red'], 'more names' => ['tags', 'more tags']}
@lv.each do |key, value|
# if the value is from the index key and equal to key itself...
end
I'm not sure how to get the value from @lv. Lets say I want to get apple:
Is there something like @lv[0] should equal apple? Because
[0] => apple
[1] => more names
right?
So I can
@lv.each do |key, value|
if @lv[0] == key
# apple equals apple, then proceed
end
end
What is the correct syntax on doing this?
Thanks!