<p>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 classes, but that doesn't help in many cases, like when you want to use things like the built in Dictionary.</p>

<p>Is there a good way to work around this problem?</p>

[{'answer_id': 51310, 'author': 'Theo', 'author_id': 1109, 'author_profile': 'https://Stackoverflow.com/users/1109', 'pm_score': 5, 'selected': True, 'text': '<p>Nope.</p>\n\n<p>But it doesn\'t hurt to add <code>equals</code> methods to your own classes. I try to never use <code>==</code>  when comparing objects (the same goes for <code>===</code>, which is the same thing for objects) since it only checks <em>identity</em> .</p>\n\n<p>Sadly all the collections in Flash and Flex assume that identity is the only measure of equality that is needed.</p>\n\n<p>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 <a href="http://livedocs.adobe.com/flex/201/langref/mx/core/IUID.html" rel="noreferrer">IUID</a>, and it is mentioned in the <em>Flex Developer\'s Guide</em> , 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.</p>\n\n<p>I\'ve written some more about this (in the context of Flex) on my blog: <a href="http://blog.iconara.net/2007/11/25/architectural-atrocities-part-8-is-there-no-equality/" rel="noreferrer">Is there no equality?</a>.</p>\n'}, {'answer_id': 8990899, 'author': 'average Joe', 'author_id': 667700, 'author_profile': 'https://Stackoverflow.com/users/667700', 'pm_score': 2, 'selected': False, 'text': '<p>Yes it can be done (but be careful, its hacky): <a href="http://filimanjaro.com/2012/operators-overloading-in-as3-javascript-too-%E2%80%93-workaround/" rel="nofollow">http://filimanjaro.com/2012/operators-overloading-in-as3-javascript-too-%E2%80%93-workaround/</a></p>\n\n<p>In the tutorial I wrote about +=, -= operator overloading. But it\'s also possible with ==, I can write more about that if it\'s not clear.</p>\n\n<p>Ah, the approach has some drawback (in rare cases it can be even dangerous). Think twice, before using it in a production.</p>\n\n<p><strong>EDIT:</strong></p>\n\n<p>After tests it seems the trick with +=, -= doesn\'t apply to == operator (what makes sense). Sorry for misleading info.</p>\n'}]
['https://Stackoverflow.com/questions/51007', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1815/']