Joined July 2013
·

Daniel

Israel
·
·

Posted to Diving into ruby hashes over 1 year ago

only this causes a rather crazy situations where

h["elad"]["adam"]["hungry"] = "always"
h["elad"]["adam"]["hungry"] # => nil

another approach would be:

class NestedHash < Hash  
  def initialize(*args)  
    inner_hash = lambda {|h,k| h[k] =  Hash.new &inner_hash   }  
    super(*args, &inner_hash)  
  end  
end  
Achievements
19 Karma
0 Total ProTip Views