Hi --

On Fri, 15 Aug 2008, Ray Pereda wrote:

> Sebastian Hungerecker wrote:
>> Hash.new {|h,k| h[k] = Hash.new(&h.default_proc)}
>
> Thanks for the attempt.  Seems on the right track but not quite.
>
>>> h = Hash.new {|h,k| h[k] = Hash.new(&h.default_proc)}
> => {}
>>> h["a"]["b"]["c"]
> => {}
>>> h
> => {"c"=>{}}
>
> After h["a"]["b"]["c"]
> what needs to happen is h is equal to
> {"a"=>{"b"=>{"c"=>{}}}}

I think it's a variable clobbering issue. Try this:

hash = Hash.new {|h,k| h[k] = Hash.new(&h.default_proc) }


David

-- 
Rails training from David A. Black and Ruby Power and Light:
  *  Advancing With Rails    August 18-21    Edison, NJ
  * Co-taught by D.A. Black and Erik Kastner
See http://www.rubypal.com for details and updates!