One of the things I miss the most in ActionScript is the lack of operator overloading, in particular ==. I kind of work around this issue by adding a \"Compare\" method to my cl
Nope.
But it doesn't hurt to add equals
methods to your own classes. I try to never use ==
when comparing objects (the same goes for ===
, which is the same thing for objects) since it only checks identity .
Sadly all the collections in Flash and Flex assume that identity is the only measure of equality that is needed.
There are hints in Flex that someone wanted to alleviate this problem at one time, but it seems like it was abandoned: there is an interface called IUID, and it is mentioned in the Flex Developer's Guide , but it is not used anywhere. Not even the collections in Flex use it to determine equality. And since you are asking for a solution for Flash, it may not have helped you anyway.
I've written some more about this (in the context of Flex) on my blog: Is there no equality?.