2010/2/2 yermej <yermej / gmail.com>:
> On Feb 1, 11:35   䲮
>> 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.

Actually, no. :-)  But you are right, this is certainly an option in
many cases.  It all depends on the situation and we do know nothing
about the "surrounding" code.

I rather tried to help Jack solve this for himself since it's not too
tricky.  Providing the full solution is not always the best choice
IMHO.

Kind regards

robert

-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/