iterating an array with a hash

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

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']

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']