Okay, I was doing some quick experiments with conj today, and I
stumbled across the following behavior. The first step works great.
user=> (conj {} [:a 1])
{:a 1}
Then I hit some different casting errors:
user=> (conj {} (seq [:a 1]))
#<CompilerException java.lang.ClassCastException: clojure.lang.Keyword
cannot be cast to java.util.Map$Entry (NO_SOURCE_FILE:...)>
user=> (conj {} '(:a 1))
#<CompilerException java.lang.ClassCastException: clojure.lang.Keyword
cannot be cast to java.util.Map$Entry (NO_SOURCE_FILE:...)>
This behavior becomes a pain when trying to use into:
;Good
user=> (into {} [[:a 1] [:b 2] [:c 3] [:d 4]])
{:a 1, :b 2, :c 3, :d 4}
;Bad
user=> (into {} (partition 2 [:a 1 :b 2 :c 3 :d 4]))
#<CompilerException java.lang.ClassCastException: clojure.lang.Keyword
cannot be cast to java.util.Map$Entry (NO_SOURCE_FILE:...)>
Is this a bug? Should the conj method of APersistentMap be re-written
to cast a wider variety of stuff to a Map$Entry? Or, is this just the
behavior of conj, and I should get used to it?
Sean
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en