问题
Is it possible to override the equals() operator (ie. for customer classes where equality may be determined by 2 or more fields matching).
回答1:
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...
回答2:
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.
来源:https://stackoverflow.com/questions/818750/is-there-a-way-to-override-action-scripts-operators-in-particular-i-would-like