Is there any way in clojure to check the equality of strings?
i.e. I need to know, whether their contents is equal, not location.
thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Equality in Clojure (the
=function) always tests value, not identity, so two strings are=if they have the same contents.For most Java types, including String, Clojure
=dispatches to Java.equals. String.equals is defined as “represents the same sequence of characters.”If you want to test identity (Are these pointers to the same location in memory?) use the
identical?function.