public
Last active

  • Download Gist
"simple".clj
Clojure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
; 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

hashing is hard.

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.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.