Created
August 31, 2016 21:13
-
-
Save warmwaffles/7f0b76701179e6a3a45041280c7dea7d to your computer and use it in GitHub Desktop.
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
class Hash | |
def pile(key, *args) | |
if args.count < 2 | |
self[key] = args[0] | |
else | |
self[key] ||= {} | |
self[key].pile(args.shift, *args) | |
end | |
end | |
end | |
h = {} | |
h.pile(:a, :b, :c, 2) | |
# => {:a=>{:b=>{:c=>2}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment