On Thu, Jan 19, 2012 at 10:19 AM, Nicolas Garcin < nicolas.etienne.gar...@gmail.com> wrote:
> Hi, > > I have a simple question regarding identical?: > I understand that keywords with the same name refer to the same > object. So > > (identical? :ab :ab) > > returns true. > Now, if I do the following thing: > > (identical? "ab" (str "a" "b")) > > I get false, because my 2 strings are not the same objects even if > they represent the same sequence of characters. > Now, when I do this: > > (identical? "ab" "ab") > > I get true. Could someone explain me why these 2 strings are the same > object? > I think this topic was already adressed here: > > http://groups.google.com/group/clojure/browse_thread/thread/c3d8d6101eb3a323/7a9f69ff900c2bab?lnk=gst&q=identical#7a9f69ff900c2bab > and here > http://groups.google.com/group/clojure/browse_thread/thread/e43af17a0424b1cd > but I did not understand everything. > > Thanks a lot for your help, > > Regards, > Nicolas Using identical? is an anti-pattern. For strings there is no guarantee. Always use =, unless you actually need identical?. You needn't worry much about performance since = uses identical? for one its first checks. David -- 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