How do I iterate through an array if I have the specific index?
@lv = {'apple' => ['round', 'red'], 'name' => ['tags', 'more tags']} if params[:value] @lv.each do |key, tags| if params[:value] == key tags.each_with_index do |tag, index| ... should display round and red? end end end end I have an array @lv and I want to be able to get the values if there's a parameter associated with it. example:
someURL.com/?value=0 Then this is supposed to get the key apple. I want to get the values from apple which should be round and red. My logic in the above codes is wrong, but I'm trying to figure out what is the syntax to call out the correct key to iterate?
@lvis a map, not an array. Using numeric indices on a map is strange.