3 ms·
Actually, no. Many languages implement == as a operation on the object itself, i.e. invokes a method named == on the object on the left side of the statement.
by rpdillon 17y ago
Actually, no. Many languages implement == as a operation on the object itself, i.e. invokes a method named == on the object on the left side of the statement. If the things you are comparing are not the same class, then == is very much a directed relation. I agree that logically it might not be, but in many implementations, it actually is.
- abecedarius 17y agoWhen it's that kind of comparison, that's an argument for putting the constant on the left. Then you'll know you're getting the kind of equality method defined for the constant (which is more typically what you want).