Data type comparisons
4 months ago
2 months ago
This spreadsheet should be read row-wise. For example, if you're checking for FALSE and receive an empty array, you'll proceed as if you received FALSE. However if you're checking for an empty array and receive FALSE, you'll proceed as if you didn't receive an empty array.
This reference is more for peace of mind than for practical use. You should generally compare objects with the same data type to increase readability and predictability.
There are cases where you can shorten your actions by comparing objects with different data types. For example, suppose a variable A is storing a vector and you want to check that it's not the zero vector. Instead of comparing
A != (0, 0, 0), you could compare
A == TRUE. On the other hand you shouldn't compare
A != 0 since
(0, 0, 0) != 0.
Another potential use case would involve 'undeclared' variables. Variables appear as
0 in the inspector by default, which represents null in this case. We know that null implies false, so it's safe to assume that undeclared variables will not equal true.
The spreadsheet also notes what appending to various data types produces. Appending to anything except an empty array will leave something at index 0. It's therefore necessary to initialise array variables to an empty array before appending to them, assuming you'd like to use index 0 before changing it.