Skip to content

Commit 7b7952a

Browse files
authored
Clarify type-safety of as
Changed the statement about the as keyword's type-safety to clarify that it is less type-safe than type hints.
1 parent cce8630 commit 7b7952a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tutorials/scripting/gdscript/gdscript_styleguide.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,10 @@ that type will be used to infer the type of the var.
10501050
@onready var health_bar := get_node("UI/LifeBar") as ProgressBar
10511051
# health_bar will be typed as ProgressBar
10521052

1053-
This option is also considered more :ref:`type-safe<doc_gdscript_static_typing_safe_lines>` than the first.
1053+
1054+
.. note::
1055+
1056+
This option is considered less :ref:`type-safe<doc_gdscript_static_typing_safe_lines>` than type hints, as it silently casts the variable to null in case of a type mismatch at runtime, without an error/warning
10541057

10551058
**Bad**:
10561059

0 commit comments

Comments
 (0)