Name
Assert -- fail if given expression is false (V5.0)
Synopsis
Assert(expr)
Function
This command checks whether or not the given expression is False (or Nil) and causes an error if this is the case. This is mainly useful for debugging purposes. You can also pass a table or a function in expr. In that case, expr will be considered True.

This call can be disabled by specifying the ‘-nodebug’ console argument when running a script or applet. In that case, calling Assert() will do nothing at all. See Console arguments for details.

Inputs
expr
expression to check
Example
a = 5
b = 0
Assert(b <> 0)
c = a / b
In the above code, Assert() is used to make sure that we don't divide by zero. Assert() will prevent such an error by checking b against zero.

Show TOC