+2 votes

I saw it in the HTTP class usage example and got a bit confused:

assert( err == OK ) # Make sure all is OK

So, does it simply checks if a statement is true or there's some deeper meaning?

in Engine by (195 points)

1 Answer

+3 votes
Best answer

This means if error is not OK terminate the program.
assert means check if the condition is false then just terminate the program.

by (580 points)
selected by
I would specify that it only checks the condition in debug mode. Also the program does not terminate, but prints an script error: "Assertion failed."
If running from the editor, the debugger will catch this error.
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.