Skip to content

Commit 0140310

Browse files
authored
Fix good/bad example order
Moved the bad example below the good example to stay consistent with previous instances.
1 parent 5a46a02 commit 0140310

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tutorials/scripting/gdscript/gdscript_styleguide.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,27 +1032,29 @@ the function's return type. For example, ``get_node()`` cannot infer a type
10321032
unless the scene or file of the node is loaded in memory. In this case, you
10331033
should set the type explicitly.
10341034

1035-
**Bad**:
1035+
**Good**:
10361036

1037-
.. rst-class:: code-example-bad
1037+
.. rst-class:: code-example-good
10381038

10391039
::
10401040

1041-
# The compiler can't infer the exact type and will use Node
1042-
# instead of ProgressBar.
1043-
@onready var health_bar := get_node("UI/LifeBar")
1041+
@onready var health_bar: ProgressBar = get_node("UI/LifeBar")
10441042

1045-
**Good**:
1043+
**Bad**:
10461044

1047-
.. rst-class:: code-example-good
1045+
.. rst-class:: code-example-bad
10481046

10491047
::
10501048

1051-
@onready var health_bar: ProgressBar = get_node("UI/LifeBar")
1049+
# The compiler can't infer the exact type and will use Node
1050+
# instead of ProgressBar.
1051+
@onready var health_bar := get_node("UI/LifeBar")
10521052

10531053
Alternatively, you can use the ``as`` keyword to cast the return type, and
10541054
that type will be used to infer the type of the var.
10551055

1056+
**Good**:
1057+
10561058
.. rst-class:: code-example-good
10571059

10581060
::

0 commit comments

Comments
 (0)