Skip to content
Create a gist now

Instantly share code, notes, and snippets.

; 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
@sjl
Owner
sjl commented Nov 9, 2012

hashing is hard.

@sjl
Owner
sjl commented Nov 9, 2012

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
Something went wrong with that request. Please try again.