diff --git a/tutorials/scripting/gdscript/gdscript_basics.rst b/tutorials/scripting/gdscript/gdscript_basics.rst index 65588bf0a1f..5d737a526cf 100644 --- a/tutorials/scripting/gdscript/gdscript_basics.rst +++ b/tutorials/scripting/gdscript/gdscript_basics.rst @@ -224,7 +224,9 @@ in case you want to take a look under the hood. Operators ~~~~~~~~~ -The following is the list of supported operators and their precedence. +The following is the list of supported operators and their precedence. All binary operators are `left-associative `_, +including the ``**`` operator. This means that ``2 ** 2 ** 3`` is equal to ``(2 ** 2) ** 3``. Use parentheses to explicitly specify precedence you need, for +example ``2 ** (2 ** 3)``. The ternary ``if/else`` operator is right-associative. +---------------------------------------+-----------------------------------------------------------------------------+ | **Operator** | **Description** | @@ -251,10 +253,6 @@ The following is the list of supported operators and their precedence. | | | | | Multiplies ``x`` by itself ``y`` times, similar to calling | | | :ref:`pow() ` function. | -| | | -| | **Note:** In GDScript, the ``**`` operator is | -| | `left-associative `_. | -| | See a detailed note after the table. | +---------------------------------------+-----------------------------------------------------------------------------+ | ``~x`` | Bitwise NOT | +---------------------------------------+-----------------------------------------------------------------------------+ @@ -330,9 +328,7 @@ The following is the list of supported operators and their precedence. 3. For negative values, the ``%`` operator and ``fmod()`` use `truncation `_ instead of rounding towards negative infinity. This means that the remainder has a sign. If you need the remainder in a mathematical sense, use the :ref:`posmod() ` and :ref:`fposmod() ` functions instead. - 4. The ``**`` operator is `left-associative `_. This means that ``2 ** 2 ** 3`` is equal to ``(2 ** 2) ** 3``. - Use parentheses to explicitly specify precedence you need, for example ``2 ** (2 ** 3)``. - 5. The ``==`` and ``!=`` operators sometimes allow you to compare values of different types (for example, ``1 == 1.0`` is true), but in other cases it can cause + 4. The ``==`` and ``!=`` operators sometimes allow you to compare values of different types (for example, ``1 == 1.0`` is true), but in other cases it can cause a runtime error. If you're not sure about the types of the operands, you can safely use the :ref:`is_same() ` function (but note that it is more strict about types and references). To compare floats, use the :ref:`is_equal_approx() ` and :ref:`is_zero_approx() ` functions instead.