QuickSand icon indicating copy to clipboard operation
QuickSand copied to clipboard

Change == operator to .equals()

Open jeremyz23 opened this issue 5 years ago • 4 comments

This provides optional future functionality allowing the .equals() to be overridden.

jeremyz23 avatar Oct 04 '18 19:10 jeremyz23

Interesting change. Could you please give a practical example on a use case for this? I am really curious

juankysoriano avatar Oct 05 '18 13:10 juankysoriano

Though the equality operator '==' compares equality of two expressions i.e. EqualityExpression == RelationalExpression. The '==' operator cannot be overridden. The .equals() function provides Object equality and can be overridden. This allows for optional future functionality with less code change without compromising the current behavior.

Granted this is an optional change rather than a necessary change.

jeremyz23 avatar Oct 05 '18 14:10 jeremyz23

But you can't override equals for a primitive value, which is the case, right? long timesAnimationViewed, long currentDuration

juankysoriano avatar Oct 05 '18 16:10 juankysoriano

This is true. If the datatypes of the two primitive parameters are always primitives then the change is unnecessary. If they are ever anything else (Objects) then the .equals() method will be optimal.

jeremyz23 avatar Oct 05 '18 16:10 jeremyz23