From: Marnen Laibow-Koser Date: 2010-02-02T04:23:01+09:00 Subject: Re: Adding keys to a hash in a loop Brian Candler wrote: > Jack Bauer wrote: >> Hi all, >> >> I'm trying to essentially accomplish this behavior: >> >> output.each do |item| >> output_hash << {item.name => []} >> end > > Apart from the other suggestions, you can do: > > output.each do |item| > output_hash.merge!(item.name => []) > end Yes. Although merging a single-key hash seems silly, and creates extra objects... Best, --  Marnen Laibow-Koser http://www.marnen.org marnen@marnen.org -- Posted via http://www.ruby-forum.com/.