This is actually the point of this whole debate. You would assume that contains? works like java.util.Collection.contains, but instead it means something completely semantically different. user=> (.contains [4 5 6] 4) true user=> (contains? [4 5 6] 4) false
Even worse, you do this and think it works: user=> (.contains [1 2 3] 1) true user=> (contains? [1 2 3] 1) true This isn't about having a method that does the same thing as .contains or includes? from contrib, it's about naming this method, the one that tells you if the associative thing has a particular key, something less confusing. This is just one of those things that a lot of people new to Clojure will learn the hard way at some point. And they'll probably send another email to the mailing list and we'll have the debate all over again. Once Clojure goes 1.0, this problem is permanent, so we have until then to convince Rich to rename this method to contains-key? (which mimics the name in the java.util.Map interface) or has-key? (for something shorter). Maybe I'll setup http://pleaserenamecontainsrich.com :) On Thu, Jan 29, 2009 at 6:55 PM, Kevin Downey <redc...@gmail.com> wrote: > actually rhickey showed up on irc and pointed something out: > > 15:23 rhickey : user=> (.contains [1 2 3] 2) > 15:23 rhickey : true > 15:23 rhickey : user=> (.contains '(1 2 3) 2) > 15:23 rhickey : true > 15:23 rhickey : what contains debate? :) > > > so because seqs, vectors, etc are java collections > > user=> (.contains (map #(.getName %) (.getMethods (class (seq [:a])))) > "contains") > true > > http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collection.html > > On Thu, Jan 29, 2009 at 3:38 PM, Jason Wolfe <jawo...@berkeley.edu> wrote: > >> >> > In that case, it makes me think of the degenerate example (I realize >> > this is slightly stupid): >> > >> > (some #{false} (list false)) >> >> Maybe this is an argument for adding "any?" to the list of core >> functions? >> >> -Jason >> >> > > > -- > And what is good, Phaedrus, > And what is not good— > Need we ask anyone to tell us these things? > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 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 -~----------~----~----~----~------~----~------~--~---