From: "Jesús Gabriel y Galán" Date: 2009-02-07T19:09:33+09:00 Subject: Re: Special Hash Constructors On Sat, Feb 7, 2009 at 5:34 AM, Simon Krahnke wrote: > * Robert Klemme (18:05) schrieb: >> def Hash.with_hashes >> new {|h,k| h[k] = Hash.new(&h.default_proc)} >> end > > I'm too tired for that. Does that create Hash with a default proc that > is the same as the one you specify right there? Yes, it achieves having infinitely nested hashes: irb(main):001:0> def Hash.with_hashes irb(main):002:1> new {|h,k| h[k] = Hash.new(&h.default_proc)} irb(main):003:1> end => nil irb(main):004:0> h = Hash.with_hashes => {} irb(main):005:0> h[1][2][3] = true => true irb(main):006:0> h => {1=>{2=>{3=>true}}} I agree that it would be nice to have them in the standard library, but maybe Hash.of_hashes and Hash.of_arrays would be better names? Jesus.