equalityassemblyscript

Does the triple equal sign (===) behave differently in AssemblyScript?


A vendor I use packages their software with AssemblyScript. They provide some infrastructure and I build on top of it.

Accidentally, I changed my double equal signs ("==") to triple equal signs ("===") in a function that performs equality checks on hexadecimal strings. I spent hours ensuring that the values checked are indeed equal and have the same case sensitivity, but nothing could make the if statement enter the branch I was expecting it to enter, except for going back to "==".

And so I ended up here, asking for help. How is "===" different to "==" in AssemblyScript? Is it some quirk of the language itself or the vendor's parser?


Solution

  • No. In modern AssemblyScript, === and == are the same thing. See docs.

    But in earlier versions yes, triple equals (===) would compare raw references and skip overloading equality operator (==). See old docs. This was changed in #2157.