Re: Can't lookup java.lang.Long keys in a map using int literal

2009-01-13 Thread Mark Engelberg
It might be nice if there were a function that automatically converted the number to the type that Clojure uses for that number if typed in as a literal. On Tue, Jan 13, 2009 at 7:27 PM, Stuart Sierra wrote: > > FYI, You can coerce to specific types with the functions int, long, > short, etc. Y

Re: Can't lookup java.lang.Long keys in a map using int literal

2009-01-13 Thread Stuart Sierra
On Jan 13, 11:18 am, Allen Rohner wrote: > I thought I was using all ints, but it turns out that a java API > returned a long when I thought it returned an int. FYI, You can coerce to specific types with the functions int, long, short, etc. You could use that when creating your map to ensure th

Re: Can't lookup java.lang.Long keys in a map using int literal

2009-01-13 Thread Allen Rohner
I still find this confusing, but thanks for the quick response. > In general, you should use uniform types for hash keys. I thought I was using all ints, but it turns out that a java API returned a long when I thought it returned an int. So then my map had some keys that were ints and some that

Re: Can't lookup java.lang.Long keys in a map using int literal

2009-01-13 Thread Rich Hickey
On Jan 13, 1:26 am, Allen Rohner wrote: > Keys in a map that are of type long can't be looked up in a map using > int literal syntax: > > user=> (def my_map { (java.lang.Long. "42") "foo"}) > #'user/my_map > > user=> my_map > {42 "foo"} > > user=> (my_map 42) > nil > > user=> (my_map (long 42))

Can't lookup java.lang.Long keys in a map using int literal

2009-01-12 Thread Allen Rohner
Keys in a map that are of type long can't be looked up in a map using int literal syntax: user=> (def my_map { (java.lang.Long. "42") "foo"}) #'user/my_map user=> my_map {42 "foo"} user=> (my_map 42) nil user=> (my_map (long 42)) "foo" user=> (= 42 (java.lang.Long. "42")) true I found this b