Skip to content

Instantly share code, notes, and snippets.

@oreoshake
Last active December 14, 2015 19:48
Show Gist options
  • Save oreoshake/5138970 to your computer and use it in GitHub Desktop.
Save oreoshake/5138970 to your computer and use it in GitHub Desktop.
hash of arrays, never again
1.9.3-p327 :002 > a = {:b => [3,4,5]}
=> {:b=>[3, 4, 5]}
1.9.3-p327 :003 > b = a.dup
=> {:b=>[3, 4, 5]}
1.9.3-p327 :004 > b[:b] << 'asdf'
=> [3, 4, 5, "asdf"]
1.9.3-p327 :005 > a
=> {:b=>[3, 4, 5, "asdf"]}
1.9.3-p327 :006 > b
=> {:b=>[3, 4, 5, "asdf"]}
1.9.3-p327 :007 >
a = {:b => [3,4,5]}
b = a.dup
b[:b] << 'asdf'
a == b # should be false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment