Hi --

On Mon, 8 Jan 2001, Jean Michel wrote:

> The problem  is that  the chosen implementation  of Hash#default  is not
> good, I think. 
[...]
>   a.default=""
>   a[1]+="a"
>   a[2]+="b"
>  
> a  is  {1=>"ab",  2=>"ab"},  not  {1=>"a",  2=>"b"}  as  it  should  be.
> Internally Hash should  call dup on a.default when creating  a new entry
> to get the desired behaviour.

I tend to agree, at least it took me a while to realize that every
key's default value was the same object and definitely involved
non-minimal amounts of surprise :-)

I'm wondering, though -- does anyone have an example of a case where
having it be the same object is useful?  I can't think of any, but I'd
like to know what they are or might be.


David


P.S. Thanks for the sort routine for my String#sort extension -- I tried
to send you email but it kept timing out.

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav