Browse Source

Add bang operator to operators table (#6558)

* Add bang operator to operators table

* Add symbolic aliases for `and` & `or`

* Remove comma from operators table

* Add bang to the aliases list

---------

Co-authored-by: Max Hilbrunner <[email protected]>
Thiago Lages de Alencar 2 years ago
parent
commit
8a112dcef2

+ 8 - 5
tutorials/scripting/gdscript/gdscript_basics.rst

@@ -274,16 +274,19 @@ The following is the list of supported operators and their precedence.
 +--------------------------------------------------------------------------------+-------------------------------------------+
 +--------------------------------------------------------------------------------+-------------------------------------------+
 | ``in``                                                                         | Inclusion checker (when used with         |
 | ``in``                                                                         | Inclusion checker (when used with         |
 |                                                                                | control flow keywords or in a             |
 |                                                                                | control flow keywords or in a             |
-|                                                                                | standalone expression).                   |
+|                                                                                | standalone expression)                    |
 |                                                                                |                                           |
 |                                                                                |                                           |
 |                                                                                | Content iterator (when used with the      |
 |                                                                                | Content iterator (when used with the      |
-|                                                                                | for_ keyword).                            |
+|                                                                                | for_ keyword)                             |
 +--------------------------------------------------------------------------------+-------------------------------------------+
 +--------------------------------------------------------------------------------+-------------------------------------------+
-| ``not``                                                                        | Boolean NOT                               |
+| ``not`` ``!``                                                                  | Boolean NOT and its                       |
+|                                                                                | :ref:`aliases<boolean_operators>`         |
 +--------------------------------------------------------------------------------+-------------------------------------------+
 +--------------------------------------------------------------------------------+-------------------------------------------+
-| ``and``                                                                        | Boolean AND                               |
+| ``and`` ``&&``                                                                 | Boolean AND and its                       |
+|                                                                                | :ref:`aliases<boolean_operators>`         |
 +--------------------------------------------------------------------------------+-------------------------------------------+
 +--------------------------------------------------------------------------------+-------------------------------------------+
-| ``or``                                                                         | Boolean OR                                |
+| ``or`` ``||``                                                                  | Boolean OR and its                        |
+|                                                                                | :ref:`aliases<boolean_operators>`         |
 +--------------------------------------------------------------------------------+-------------------------------------------+
 +--------------------------------------------------------------------------------+-------------------------------------------+
 | ``if x else``                                                                  | Ternary if/else                           |
 | ``if x else``                                                                  | Ternary if/else                           |
 +--------------------------------------------------------------------------------+-------------------------------------------+
 +--------------------------------------------------------------------------------+-------------------------------------------+

+ 4 - 2
tutorials/scripting/gdscript/gdscript_styleguide.rst

@@ -407,6 +407,8 @@ they only reduce readability.
     if (is_colliding()):
     if (is_colliding()):
         queue_free()
         queue_free()
 
 
+.. _boolean_operators:
+
 Boolean operators
 Boolean operators
 ~~~~~~~~~~~~~~~~~
 ~~~~~~~~~~~~~~~~~
 
 
@@ -425,7 +427,7 @@ This can make long expressions easier to read.
 
 
 ::
 ::
 
 
-    if (foo and bar) or baz:
+    if (foo and bar) or not baz:
         print("condition is true")
         print("condition is true")
 
 
 **Bad**:
 **Bad**:
@@ -434,7 +436,7 @@ This can make long expressions easier to read.
 
 
 ::
 ::
 
 
-    if foo && bar || baz:
+    if foo && bar || !baz:
         print("condition is true")
         print("condition is true")
 
 
 Comment spacing
 Comment spacing