Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View "simple".clj
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
Owner

hashing is hard.

Owner

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.