Created
November 9, 2012 05:09
-
-
Save sjl/4043824 to your computer and use it in GitHub Desktop.
This file contains 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
; Integers and Longs are equal. | |
(= (Integer. 1) (Long. 1)) | |
true | |
; Even negative ones. | |
(= (Integer. -1) (Long. -1)) | |
true | |
; When you use them as keys in maps, the maps are still equal. | |
(= {(Integer. 1) :foo} {(Long. 1) :foo}) | |
true | |
(= {(Integer. -1) :foo} {(Long. -1) :foo}) | |
true | |
; When you use positive numbers as keys to sets, they're also equal. | |
(= #{(Integer. 1)} #{(Long. 1)}) | |
true | |
; But negative ones aren't. But only in sets. Maps are fine. lol. | |
(= #{(Integer. -1)} #{(Long. -1)}) | |
false |
Oh and just to laugh in my face:
#{(Integer. -1) (Long. -1)}
complains about a duplicate key. That little shitbag Mr. PersistentHashSet
knows those keys are equal but won't let on when comparing.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hashing is hard.