From: Robert Klemme Date: 2010-02-02T02:45:08+09:00 Subject: Re: Adding keys to a hash in a loop On 01.02.2010 18:35, Jack Bauer wrote: > I'm trying to essentially accomplish this behavior: > > output.each do |item| > output_hash<< {item.name => []} > end > > So that I can end up with: > > {"first_set" => [], "second_set" => [], "third_set" => [], ... } > > I know the first block of code won't work, but it's just to illustrate > what it is I wish to accomplish. Can anyone help me out? Thanks. Erm, how would you put a key value pair into a Hash without a loop? http://www.ruby-doc.org/core/classes/Hash.html Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/