Is there a way to override action scripts operator

2019-07-18 15:56发布

Is it possible to override the equals() operator (ie. for customer classes where equality may be determined by 2 or more fields matching).

2条回答
该账号已被封号
2楼-- · 2019-07-18 16:07

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.

查看更多
家丑人穷心不美
3楼-- · 2019-07-18 16:17

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...

查看更多
登录 后发表回答