Skip to content

Commit 2ec67eb

Browse files
authored
Merge pull request #10782 from Lexyth/patch-4
Fix misplaced bad example
2 parents e263ffd + 4b04e65 commit 2ec67eb

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

tutorials/scripting/gdscript/gdscript_styleguide.rst

+10-8
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,16 @@ should set the type explicitly.
10401040

10411041
@onready var health_bar: ProgressBar = get_node("UI/LifeBar")
10421042

1043+
**Bad**:
1044+
1045+
.. rst-class:: code-example-bad
1046+
1047+
::
1048+
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")
1052+
10431053
Alternatively, you can use the ``as`` keyword to cast the return type, and
10441054
that type will be used to infer the type of the var.
10451055

@@ -1052,12 +1062,4 @@ that type will be used to infer the type of the var.
10521062

10531063
This option is also considered more :ref:`type-safe<doc_gdscript_static_typing_safe_lines>` than the first.
10541064

1055-
**Bad**:
10561065

1057-
.. rst-class:: code-example-bad
1058-
1059-
::
1060-
1061-
# The compiler can't infer the exact type and will use Node
1062-
# instead of ProgressBar.
1063-
@onready var health_bar := get_node("UI/LifeBar")

0 commit comments

Comments
 (0)