Skip to content

Commit

Permalink
Document constants being flat in GDScript
Browse files Browse the repository at this point in the history
  • Loading branch information
Calinou committed Jun 29, 2020
1 parent 13f7e96 commit d01c6c6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion getting_started/scripting/gdscript/gdscript_basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand All @@ -641,6 +641,13 @@ 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 still can't be reassigned with another value
though.

Enums
^^^^^

Expand Down

0 comments on commit d01c6c6

Please sign in to comment.