Created
February 17, 2013 13:57
-
-
Save psychocandy/4971593 to your computer and use it in GitHub Desktop.
Autovivification which allows you to nest away and save you a lot of nil? checks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hash = Hash.new { |h,k| h[k] = Hash.new(&h.default_proc) } | |
hash[:foo]["bar"][:baz] = 13 | |
# => {:foo=>{"bar"=>{:baz=>13}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment