Skip to content

Instantly share code, notes, and snippets.

@xhoy
Created January 21, 2015 16:30
Show Gist options
  • Save xhoy/e992ee7a5a9e1e1bc6a5 to your computer and use it in GitHub Desktop.
Save xhoy/e992ee7a5a9e1e1bc6a5 to your computer and use it in GitHub Desktop.
WTF?
2.0.0-p594 :036 > x
=> nil
2.0.0-p594 :037 > x = {}
=> {}
2.0.0-p594 :038 > y = x
=> {}
2.0.0-p594 :039 > z = x
=> {}
2.0.0-p594 :040 > y["foo"] = "bar"
=> "bar"
2.0.0-p594 :041 > z
=> {"foo"=>"bar"}
2.0.0-p594 :042 > y
=> {"foo"=>"bar"}
2.0.0-p594 :043 > x
=> {"foo"=>"bar"}
2.0.0-p594 :044 > a = "asd"
=> "asd"
2.0.0-p594 :045 > b = a
=> "asd"
2.0.0-p594 :046 > c = a
=> "asd"
2.0.0-p594 :047 > b = "xyz"
=> "xyz"
2.0.0-p594 :048 > a
=> "asd"
2.0.0-p594 :049 > b
=> "xyz"
2.0.0-p594 :050 > c
=> "asd"
2.0.0-p594 :051 >
Why is a Hash different from a String?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment