Skip to content

Instantly share code, notes, and snippets.

@alexrothenberg
Created November 16, 2012 18:58
Show Gist options
  • Save alexrothenberg/4089904 to your computer and use it in GitHub Desktop.
Save alexrothenberg/4089904 to your computer and use it in GitHub Desktop.
hash weirdness
h = Hash.new([])
h[:a] << 1
h[:a] << 2
h
#=> {} # WTF
h.keys
#=> [] # WTF
h[:a]
#=> [1, 2] # OK
h[:b] = 3
h
#=> {:b=>3} # where is a?
h.keys
#=> [:b] # where is a?
h[:b]
#=> 3 # OK
h[:a]
#=> [1, 2] # OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment