Examples of Expire Binding as a Timer:
I would wait for an error in the logs before I would blindly switch over to using !== and === verses != and == because the two are really two different operations and it is not entirely clear to me yet exactly when the rules parser complains about it.
== calls the .equals method but === does a Java identity equals. Thus if I had:
val string1 = "foo"
val string2 = "foo"
operator | result | comment |
---|---|---|
string1 == string2 | true | compares each letter in the two strings |
string1 != string2 | false | comares each letter in the two strings |
string1 === string2 | false | determines if both variables point to the same place in memory |
string1 !== string2 | true | determines if both variables point to different places in memory |
As you can see, in this case, == and === produce exactly opposite results.
The reason why string1 === string2 doesn’t work as expected is because string1 and string2 are not literally the same object and === only compares the memory address the variables point to.
Unfortunately, this is something built into the base language and not something I think we can get rid of in OH 2, but were I king for a day I would find a way to make == smarter and do away with === because it is only going to continue to cause major headaches going forward.