Improve @GDScript.assert documentation

Mention that assert only runs in debug builds, closes #29154
This commit is contained in:
Nathan Lovato 2019-06-03 19:27:37 +09:00
parent a25e52fb72
commit 6f1f887078
1 changed files with 5 additions and 5 deletions

View File

@ -92,13 +92,13 @@
<argument index="0" name="condition" type="bool"> <argument index="0" name="condition" type="bool">
</argument> </argument>
<description> <description>
Assert that the [code]condition[/code] is [code]true[/code] . If the [code]condition[/code] is [code]false[/code] a fatal error is generated and the program is halted. Useful for debugging to make sure a value is always [code]true[/code]. Asserts that the [code]condition[/code] is [code]true[/code] . If the [code]condition[/code] is [code]false[/code], an error is generated and the program is halted until you resume it. Only executes in debug builds, or when running the game from the editor. Use it for debugging purposes, to make sure a statement is [code]true[/code] during development.
[codeblock] [codeblock]
# Speed should always be between 0 and 20 # Imagine we always want speed to be between 0 and 20
speed = -10 speed = -10
assert(speed &lt; 20) # Is true and program continues assert(speed &lt; 20) # True, the program will continue
assert(speed &gt;= 0) # Is false and program stops assert(speed &gt;= 0) # False, the program will stop
assert(speed &gt;= 0 &amp;&amp; speed &lt; 20) # Or combined assert(speed &gt;= 0 &amp;&amp; speed &lt; 20) # You can also combine the two conditional statements in one check
[/codeblock] [/codeblock]
</description> </description>
</method> </method>