Variable value at creation and following that

Godot Version

4.3.stable

Question

State of a variable after its creation

This is a weird question. If you create a variable the following way :

var has_enemies = enemies.size() > 0

Does gdscript keeps updating the value of has_enemies following enemies.size() or is that value given at creation only and it has to be reevaluated manually afterward?

The latter, on creation it will evaluate, and you will need to manually check again.

All native Godot types are copy by value, and since this is also an expression, in itself cannot be held as reference, as it is more akin to a procedure then a value.

You can always imagine comparison operators like a<b as a-b where a computer will check sign bits to know it’s below zero.

1 Like

Thanks for the info. Much appreciated.

Although, I’ll admit, I’d have prefered the former. But, hey… it is what it is. :rofl: