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
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
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
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))
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