mirror of
https://github.com/godotengine/godot-docs.git
synced 2026-01-04 14:11:02 +03:00
Merge pull request #9777 from 0stam/is-not-conversion
Use the newly introduced ``is not`` operator
This commit is contained in:
@@ -272,7 +272,12 @@ get full autocompletion on the player variable thanks to that cast.
|
||||
|
||||
player.damage()
|
||||
|
||||
or ``assert()`` statement::
|
||||
You can also simplify the code by using the ``is not`` operator::
|
||||
|
||||
if body is not PlayerController:
|
||||
push_error("Bug: body is not PlayerController")
|
||||
|
||||
Alternatively, you can use the ``assert()`` statement::
|
||||
|
||||
assert(body is PlayerController, "Bug: body is not PlayerController.")
|
||||
|
||||
@@ -282,6 +287,7 @@ get full autocompletion on the player variable thanks to that cast.
|
||||
|
||||
player.damage()
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
If you try to cast with a built-in type and it fails, Godot will throw an error.
|
||||
|
||||
Reference in New Issue
Block a user