Skip to content

Instantly share code, notes, and snippets.

@jaspervdj
Created June 5, 2012 17:25
Show Gist options
  • Save jaspervdj/2876378 to your computer and use it in GitHub Desktop.
Save jaspervdj/2876378 to your computer and use it in GitHub Desktop.
Ruby's Hashes' ordering vs. referential transparency
hash1 = {:foo => 1, :bar => 2}
hash2 = {:bar => 2, :foo => 1}
# #to_s is probably a bad example, but I like
# it when x == y implies that f x == f y
puts hash1 == hash2
puts hash1.to_s == hash2.to_s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment