Skip to content

Latest commit

 

History

History
16 lines (9 loc) · 231 Bytes

autovivification.md

File metadata and controls

16 lines (9 loc) · 231 Bytes

Autovivification

deep = Hash.new { |hash,key| hash[key] = Hash.new(&hash.default_proc) }


deep[:a][:b][:c][:d] = 42
p deep

# Result:
# {:a=>{:b=>{:c=>{:d=>42}}}}

View Source