sorry if this duplicates but I sent it about 5 hours ago and it hasn''t shown up yet... trying to do this in irb/console... @sect = Array.new info = { "outsection" => "I/A", "outtitle" => "I" } @sect << info info = { "outsection" => "I/B", "outtitle" => "B" } @sect << info for sect in @sect puts sect.outsection end NoMethodError: undefined method `outsection'' for {"outtitle"=>"I", "outsection"=>"I/A"}:Hash from (irb):127 from (irb):126:in `each'' from (irb):126 how do I iterate over the array to get the individual hash elements? Craig --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Craig White wrote:> puts sect.outsectionsect here is a hash, so you need to use Hash methods to access the parts: puts sect[''outsection''] -- 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 Fri, 2008-03-14 at 07:53 +0100, Mark Bush wrote:> Craig White wrote: > > puts sect.outsection > > sect here is a hash, so you need to use Hash methods to access the > parts: > > puts sect[''outsection'']---- duh...sometimes where you''re in the forest, all you see is trees. of course Thanks Craig --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---