Don't do this...This one bit me hard =)
hash = Hash.new( [ ] )
hash[:new_key] << 3
hash.length # => 0 ouch
hash.keys # => [ ] doh!
# this why this was painful...
hash[:new_key] # => [ 3 ]
hash[:another_key] # => [ 3 ]
So anyway, is there no way to have this do what I mean? or do I have
to initialize it seperately?
hash[:new_key] ||= [ ]
hash[:new_key] << 3
I'm having a total mental lapse, but I know using the block form won't
help either, i.e.:
hash = Hash.new { [ ] }
Any thoughts?
--
Lou