Based on Rich's elaboration I would be satisified if contains? threw an exception when called on a vector.
> I agree with Stuart, I can't imagine this is how anyone new to Clojure > would expect this to work: > > user=> (contains? [2 3 4] 1) > (contains? [2 3 4] 1) > true > user=> (contains? [2 3 4] 4) > (contains? [2 3 4] 4) > false > user=> (contains? (seq [2 3 4]) 1) > (contains? (seq [2 3 4]) 1) > false > user=> (contains? (seq [2 3 4]) 4) > (contains? (seq [2 3 4]) 4) > false > > The fact that contains? is semantically different than > java.util.Collection#contains is confusing. If contains? was called > contains-key?, that would be more intuitive and map to how it works in > Java. > > On Sep 30, 5:29 pm, Stuart Halloway <[EMAIL PROTECTED]> wrote: >> For your specific case you should probably be using contains?, which >> works for both. >> >> But I agree it seems odd. >> >> >> >>> The following looks weird to me: >> >>> Clojure >>> user=> (.contains [1 2 3] 2) >>> true >>> user=> (true? (.contains [1 2 3] 2)) >>> false >> >>> AFAICS true? is implemented using identical? which tests by >>> reference >>> equality. Now since Java boolean values are boxed into Booleans we >>> have >>> not only Boolean.TRUE. Maybe true? (and false?) should be >>> implemented in >>> terms of equals? > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
