From: Robert Klemme Date: 2011-12-09T23:38:18+09:00 Subject: Re: How can I do h["foo"] += "bar" if h["foo"] does not exist? On Fri, Dec 9, 2011 at 11:22 AM, Mayank Kohaley wrote: > Thanks for the enlightenment!!! Learned something about hashes today. :) You're welcome. I just had one spelling error: irb(main):012:0> h = Hash.new {|ha,k| h[k] = ""} should have been irb(main):012:0> h = Hash.new {|ha,k| ha[k] = ""} It does not make a difference in this case (since ha == h) but the corrected version is more robust (i.e. if someone reassigns h). Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/