Hello, I''m trying to iterate over a hash map I created, but its not working very well... I''ve been experimenting in IRB like so: compare_hash = {} compare_hash["item1"] = ["subitem1","subitem2"] compare_hash["item2"] = ["subitem1","subitem2"] compare_hash.each do |item| puts item[0] end instead of giving me the expected results of: subitem1 subitem2 it gives me only the names: item1 item2 Does anybody know how to do this properly? Thanks! - Jeff Miller -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 25 Apr 2008, at 22:17, Jeff Miller wrote:> > Hello, > I''m trying to iterate over a hash map I created, but its not working > very well... I''ve been experimenting in IRB like so: > > compare_hash = {} > compare_hash["item1"] = ["subitem1","subitem2"] > compare_hash["item2"] = ["subitem1","subitem2"] > > compare_hash.each do |item| > puts item[0] > end >compare_hash.each do |key, value| puts key #will output item1, item2 puts value #will out put the values end Fred> instead of giving me the expected results of: > subitem1 > subitem2 > > it gives me only the names: > item1 > item2 > > Does anybody know how to do this properly? > > Thanks! > - Jeff Miller > -- > Posted via http://www.ruby-forum.com/. > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
thanks! that worked! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---