Is there a way to override action scripts operators, in particular I would like to override the equals operator
-
03-07-2019 - |
Question
Is it possible to override the equals() operator (ie. for customer classes where equality may be determined by 2 or more fields matching).
Solution
if you mean overloading "==" as a synonym for equals() then you can't, as ActionScript doesn't offer operator overloading. Just write an equals() method for your class and use that...
OTHER TIPS
Using your own equals() method for a class doesn't solve how to check if a collection contains the desired object. In flex I've always had to write a for each and iterate over each member object to check if 2 or more fields are matching. Java allows the programmer to override hashCode() and equals() that's used automatically by collection interfaces.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow