Assert(expr)
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.
a = 5 b = 0 Assert(b <> 0) c = a / bIn 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.