From: Henry Maddocks Date: 2012-10-15T06:09:45+09:00 Subject: Re: how to join the return of array On 15/10/2012, at 10:04 AM, Ruby Mania wrote: > Thanks a bunch ! > This works like a charm but just curious why I have to initialize and > I could not just do > > out[symb] << hq.close > > without initialise Because the default value of an uninitialised hash key is nil and nil doesn't respond to << >> out = {} => {} >> out['foo'] => nil >> out['foo'] << 'bar' NoMethodError: undefined method `<<' for nil:NilClass from (irb):3 from /Users/henry/.rbenv/versions/1.9.3-p125/bin/irb:12:in `
' >> Henry