On 11/22/05, Rob Rypka <rascal1182 / gmail.com> wrote:
>
> Perhaps I'm missing something.  Is there something wrong with the following?
>
> a = Hash.new { [] }
>
> irb tells me that it gets a new array each time.

No that is how it works and that is basically what Jeff's code does.
He just has empty "goal-posts" in the block as well (it isn't really
an or operation.) He gets around the new array every time thing by
using self[key] <<= value, which is self[key] = self[key] << value.
The block will only be called when there is no values for the given
key, and once the above code is called, there will be a value for the
given key (the array.) It is pretty slick (I didn't even know <<=
existed.)

Ryan