"Dennis Decker Jensen" <dennisdecker / mail.tele.dk> writes:

> Lloyd Zusman wrote:
> >   h.get('a','b','c')
> >
> >   h.set('a','b','c','xxx')
> >
> > The `get' method would return nil (or perhaps throw an exception) if a
> > non-existent node is being referenced; and the `set' method would
> > create the internal structure as needed.
> >
> > This construct would still be easy to read, understand, and maintain.
> > And I believe that it should be relatively simple to write and use.
> 
> Couldn't Hash#default be used in this case also?
> 
> The get-method also very much looks like the behaviour of
> Hash#fetch, where you provide the default value if the key doesn't
> exist...

Well, `get' with one parameter would indeed be pretty much the same as
`fetch'.  But my proposed `get' would take an arbitrary number of
parameters, each representing another dimension of the
multidimensional hash.  But yes, I'd probably be using `fetch' within
the implementation of `get'.

And I agree that the Hash#default method should be used to supply the
return value when a non-existent node is being accessed.


> Regards,
> 
> Dennis Decker Jensen
> 

-- 
 Lloyd Zusman
 ljz / asfast.com