R
Ray Pereda
h = Hash.new {|h,k| h[k] = {} }
This is one level deep defaults to a fresh new hash.
h = Hash.new {|h,k| h[k] = Hash.new{ |h2,k2| h2[k2] = {} } }
This is two levels deep initialization to a fresh new hash.
How do I this for arbitrarily deep hashes?
h["a"]["b"]["c"] = 3 #=> {"c"=>3}
I'm using this to build very clean implementations of state machine
building algorithms.
Your help is very much appreciated.
-Ray
This is one level deep defaults to a fresh new hash.
h = Hash.new {|h,k| h[k] = Hash.new{ |h2,k2| h2[k2] = {} } }
This is two levels deep initialization to a fresh new hash.
How do I this for arbitrarily deep hashes?
h["a"]["b"]["c"] = 3 #=> {"c"=>3}
I'm using this to build very clean implementations of state machine
building algorithms.
Your help is very much appreciated.
-Ray