Merge pull request #9777 from 0stam/is-not-conversion

Use the newly introduced ``is not`` operator
This commit is contained in:
Max Hilbrunner
2024-11-17 11:34:55 +01:00
committed by GitHub

View File

@@ -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.