From: yermej Date: 2010-02-02T15:30:08+09:00 Subject: Re: Adding keys to a hash in a loop On Feb 1, 11:35 am, Jack Bauer wrote: > Hi all, > > I'm trying to essentially accomplish this behavior: > > output.each do |item| >   output_hash << {item.name => []} > end Depending on how you'll be using output_hash, you might use a default value instead of individually initializing the values. Based on your sample, you can likely use: output_hash = Hash.new {|hash, key| hash[key] = Array.new} I'm guessing this is what Robert was hinting at.