The Ruby Infinite Hash
@tenderlove shows us ruby magic to create an infinite hash:
>> hash = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
=> {}
>> hash['a'] = 1
=> 1
>> hash['a']
=> 1
>> hash['b']
=> {}
>> hash['b']['c']['d']
=> {}
This content is open source.
Suggest Improvements.