Does GDScript have an assert command?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By chanon
:warning: Old Version Published before Godot 3 was released.

Since it is easy to have typos and other small errors cause bugs in dynamically typed languages like GDScript, I would like to code in a “defensive coding” style where I verify the parameters of method calls and other inputs.

However, doing this a lot might affect performance, so I am wondering if there is some kind of assert command which is only run in debug / development to help catch errors and removed (not called) in exported / release builds?

:bust_in_silhouette: Reply From: Mohammad Hadi Aliakb


Nil assert ( bool condition )

Nice! I should have tried it first.

chanon | 2016-02-24 04:48