Skip to content

Instantly share code, notes, and snippets.

@bricker
Created March 28, 2015 04:06
Show Gist options
  • Save bricker/5ca6f58bf091d14d6203 to your computer and use it in GitHub Desktop.
Save bricker/5ca6f58bf091d14d6203 to your computer and use it in GitHub Desktop.
class SloppyHash
def [](k)
memory[k] ||= SloppyHash.new
end
def []=(k,v)
memory[k] = v
end
private
def memory
@memory ||= {}
end
end
h = SloppyHash.new
h[:a][:b][:c] = "hello"
p h[:a][:b][:c]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment