I agree about the counter-intuitiveness. I'm only wondering whether the
error message is a bit misleading "contains? not supported on type:
java.lang.String" because of course (contains? "hello" 2) works fine.
Shantanu
On Wednesday, 13 May 2015 00:12:19 UTC+5:30, James Reeves wrote:
>
> contains? has always been a little counter-intuitive. It essentially only
> works on collections that allow for a constant or logarithmic lookup time,
> and often works on the "keys" of a collection, rather than its values. The
> only exception to this are sets, where the values are essentially keys as
> well.
>
> So:
>
> (contains? {:a 1} :a) => true
> (contains? {:a 1} 1) => false
> (contains? [:a] :a) => false
> (contains? [:a] 0) => true
> (contains? #{:a} :a) => true
> (contains? "a" \a) => error
> (contains? '(:a) :a) => error
>
> - James
>
> On 12 May 2015 at 19:25, Shantanu Kumar <[email protected]
> <javascript:>> wrote:
>
>> Hi,
>>
>> I notice the following in Clojure 1.7.0-beta2:
>>
>> user=> (contains? "hello" 2)
>> true
>> user=> (contains? "hello" \e)
>>
>> IllegalArgumentException contains? not supported on type:
>> java.lang.String clojure.lang.RT.contains (RT.java:800)
>>
>>
>> Is this just a case of misleading error message or am I missing something?
>>
>> Shantanu
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to [email protected]
>> <javascript:>
>> 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] <javascript:>
>> 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 [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
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
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.