From 7b7952ae7112e324663ec28d593ea030ddf49bed Mon Sep 17 00:00:00 2001 From: Lexyth Date: Wed, 19 Mar 2025 00:37:10 +0100 Subject: [PATCH] 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. --- tutorials/scripting/gdscript/gdscript_styleguide.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tutorials/scripting/gdscript/gdscript_styleguide.rst b/tutorials/scripting/gdscript/gdscript_styleguide.rst index 6230736ea..1fe696b94 100644 --- a/tutorials/scripting/gdscript/gdscript_styleguide.rst +++ b/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` than the first. + +.. note:: + + This option is considered less :ref:`type-safe` than type hints, as it silently casts the variable to null in case of a type mismatch at runtime, without an error/warning **Bad**: