Browse Source

Merge pull request #10781 from Lexyth/patch-3

Clarify type-safety of as
Matthew 4 months ago
parent
commit
1335f389ec
1 changed files with 6 additions and 1 deletions
  1. 6 1
      tutorials/scripting/gdscript/gdscript_styleguide.rst

+ 6 - 1
tutorials/scripting/gdscript/gdscript_styleguide.rst

@@ -1060,6 +1060,11 @@ that type will be used to infer the type of the var.
     @onready var health_bar := get_node("UI/LifeBar") as ProgressBar
     @onready var health_bar := get_node("UI/LifeBar") as ProgressBar
     # health_bar will be typed as ProgressBar
     # health_bar will be typed as ProgressBar
 
 
-This option is also considered more :ref:`type-safe<doc_gdscript_static_typing_safe_lines>` than the first.
+
+.. note::
+
+    This option is considered more :ref:`type-safe<doc_gdscript_static_typing_safe_lines>` than type hints,
+    but also less null-safe as it silently casts the variable to ``null`` in case of a type mismatch at runtime,
+    without an error/warning.