Created
June 5, 2012 17:25
-
-
Save jaspervdj/2876378 to your computer and use it in GitHub Desktop.
Ruby's Hashes' ordering vs. referential transparency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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