What are their differences? Coming from a Java background, it does seem to me <=> is the same as Java’s equals(), while == is for direct reference comparison. Is this right?
Share
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.
==only measures if two objects are equal, whereas<=>should return -1 if the first object is smaller, 0 if they are equal, and 1 if the first object is greater.If you define a
<=>method for your class, you’ll get all of the other comparison operators defined as well (==,<,>, and so on).