[SOLVED] OH2: comparisons with == or ===?

Noticed the odd complaint when migrating rule file:

The operator '!=' should be replaced by '!==' when null is one of the arguments.

Are all operators to be changed from == to === and != to !== or only when comparing to null?

Or can these for consistency sake all changed to ===?

It’s a warning and it is identifying something that has always been wrong but you as the user were not warned about it until OH 2.3.

I’ve written this up two or three times but can’t find them at the moment. The tl;dr is use === and ! =j when one of the operands is explicitly null (all lower case).

It has to do with type and the fact that null isn’t an Object so didn’t have a .equals method to call (what gets called when using ==).

So, only change the ones that explicitly test null. The rest must remain ==. Your best bet is to just change the lines generating the warnings.