Skip to content

Commit

Permalink
Add documentation for GDScript when statement
Browse files Browse the repository at this point in the history
  • Loading branch information
tetrapod00 committed Aug 20, 2024
1 parent 5dd72ba commit f9a41bd
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tutorials/scripting/gdscript/gdscript_basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ in case you want to take a look under the hood.
+------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| as | Cast the value to a given type if possible. |
+------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| when | Used by :ref:`pattern guard expressions<doc_gdscript_basics_pattern_guards>` in :ref:`match<doc_gdscript_basics_match>` statements. |
+------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| self | Refers to current class instance. |
+------------+---------------------------------------------------------------------------------------------------------------------------------------------------+
| super | Resolves the scope of the parent method. See `Inheritance`_. |
Expand Down Expand Up @@ -1638,6 +1640,9 @@ be manipulated by calling methods on the loop variable.
for node in node_array:
node.add_to_group("Cool_Group") # This has an effect


.. _doc_gdscript_basics_match:

match
^^^^^

Expand Down Expand Up @@ -1787,8 +1792,10 @@ The following pattern types are available:
"Sword", "Splash potion", "Fist":
print("Yep, you've taken damage")

Pattern guards
""""""""""""""
.. _doc_gdscript_basics_pattern_guards:

Pattern guard expressions
"""""""""""""""""""""""""

Only one branch can be executed per ``match``. Once a branch is chosen, the rest are not checked.
If you want to use the same pattern for multiple branches or to prevent choosing a branch with too general pattern,
Expand Down

0 comments on commit f9a41bd

Please sign in to comment.