Method: Dictionary.auto

Defined in:
lib/extlib/dictionary.rb

.auto(*args) ⇒ Object

Alternate to #new which auto-creates sub-dictionaries as needed.

d = Dictionary.auto
d["a"]["b"]["c"] = "abc"  #=> { "a"=>{"b"=>{"c"=>"abc"}}}


128
129
130
131
132
# File 'lib/extlib/dictionary.rb', line 128

def auto(*args)
  #AutoDictionary.new(*args)
  leet = lambda { |hsh, key| hsh[key] = new(&leet) }
  new(*args, &leet)
end