aaaaaa the old 'why contains? doesn't work' discussion...even though
it's been a while since it last came up on this list, it must be the
single most popular questions :)
Jim
On 07/08/13 12:24, Goldritter wrote:
In an program I used the result of keys as an argument for a function
which verifies whether an object is in a passed collection or not.
The result I got was following Exception:
IllegalArgumentException contains? not supported on type:
clojure.lang.APersistentMap$KeySeq clojure.lang.RT.contains (RT.java:724)
What are the reasons behind this Exception?
In the documentation of contains? it is written, that
"Returns true if key is present in the given collection, otherwise
returns false."
The examples on this page
(http://clojuredocs.org/clojure_core/clojure.core/contains_q) and the
parameter description indicates, that contains? accept any collection
as argument.
The result of keys is also a collection
=> (coll? (keys {:a "f" :b 23}))
true
So is this a bug or is there a reason behind the fact, that contains?
does not accept any collection?
Or is the documentation wrong and it should nor be a collection as
argument but a set or a vector?
Because I get the same Exception for a list, but not for a vector.
The same for lists, which returns also true for coll?.
=> (coll? '(1 2 3 4))
true
=> (contains? '(1 2 3 4) 3)
IllegalArgumentException contains? not supported on type:
clojure.lang.PersistentList clojure.lang.RT.contains (RT.java:724)
=> (contains? [1 2 3 4] 3)
true
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient
with your first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.