浏览代码

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.
Lexyth 4 月之前
父节点
当前提交
7b7952ae71
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      tutorials/scripting/gdscript/gdscript_styleguide.rst

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

@@ -1050,7 +1050,10 @@ that type will be used to infer the type of the var.
     @onready var health_bar := get_node("UI/LifeBar") 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 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
 
 **Bad**: