Document constants being flat in GDScript

See https://github.com/godotengine/godot/issues/30212.
This commit is contained in:
Hugo Locurcio
2020-06-29 10:06:04 +02:00
parent 13f7e9669c
commit bb143bc497

View File

@@ -631,7 +631,7 @@ expressions and must be assigned on initialization.
const E = [1, 2, 3, 4][0] # Constant expression: 1.
const F = sin(20) # 'sin()' can be used in constant expressions.
const G = x + 20 # Invalid; this is not a constant expression!
const H = A + 20 # Constant expression: 25.
const H = A + 20 # Constant expression: 25 (`A` is a constant).
Although the type of constants is inferred from the assigned value, it's also
possible to add explicit type specification::
@@ -641,6 +641,12 @@ possible to add explicit type specification::
Assigning a value of an incompatible type will raise an error.
.. note::
Since arrays and dictionaries are passed by reference, constants are "flat".
This means that if you declare a constant array or dictionary, it can still
be modified afterwards. They can't be reassigned with another value though.
Enums
^^^^^