Skip to content

Instantly share code, notes, and snippets.

@warmwaffles
Created August 31, 2016 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warmwaffles/7f0b76701179e6a3a45041280c7dea7d to your computer and use it in GitHub Desktop.
Save warmwaffles/7f0b76701179e6a3a45041280c7dea7d to your computer and use it in GitHub Desktop.
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