Missing documentation on "truthy" and "falsy" values

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Lemoneese

I noticed that Vector2.ZERO is evaluated as a false value when casted to bool (if Vector2.ZERO same as if false). I looked through the docs (specifically this one on bool) and didn’t find anything discussing about this behavior. Even though this behavior is expected, it’d be nice if the docs included this information. Or at the very least, it’d be nice if someone can point me to the right page for it.

:bust_in_silhouette: Reply From: jgodfrey

This is documented on the Vector2 page itself with this statement:

Note: In a boolean context, a Vector2 will evaluate to false if it’s equal to Vector2(0, 0). Otherwise, a Vector2 will always evaluate to true.

And, more generally, this is documented on the specific datatype pages where it applies. For example, this search turns up a number of references similar to the one I linked above:

Search — Godot Engine (stable) documentation in English

jgodfrey | 2023-06-22 22:58