Back to wiki
This post is unpublished.
Double check all the info, and if it's ready, click the "publish" button in the post summary.

Data type comparisons

Author:
Corrade

Category:
References

Posted:
4 months ago

Revisions:
9 revisions

Last updated:
2 months ago

Findings

You can find the spreadsheet for this topic here or reference the image below. The code for the mode used to gather data is available at this git repo.

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.

Applications

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.

Appending

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.