On Thu, Nov 5, 2009 at 8:25 AM, Robert Klemme
<shortcutter / googlemail.com> wrote:
> On 11/04/2009 06:10 PM, Aldric Giacomoni wrote:
>>
>> Robert Klemme wrote:
>>>
>>> IMHO this solution is even simpler because it does not need the method:
>>>
>>> h = Hash.new {|h,k| h[k] = Hash.new(&h.default_proc)}
>>
>> Robert - I agree. I like this one better. Feels a little more ruby-ish.
>> Is there a way to use Proc (or whatever does work) to save this block and
>> reuse it when creating a new hash ?
>
> The block *is* saved and reused when creating nested Hashes!
>
>> Something like :
>> a = Proc.new {|h,k| h[k] = Hash.new(&h.default_proc)}
>> b = Hash.new a
>>
>> Note, I know this is wrong.. It'll just put the proc as the default value,
>> instead of triggering the proc.
>
> No need for that.  ¨Âìåáóìïïë áô íù ãïäå áçáéî®

I think he might want to save typing:

a = Proc.new {|h,k| h[k] = Hash.new(&h.default_proc)}
b = Hash.new &a
c = Hash.new &a
d = Hash.new &a

Maybe this is his use case?

Jesus.