Asserts that condition is not nil and not false
Raises an error if value of v is nil or false.
It is very useful that assert returns the value on success, as you can build an assert into the same line that does something that might fail. For example:
In this case if the loadstring function succeeds it returns a function, that is then executed by the final brackets, otherwise you get an error message.
See Also ...
collectgarbage - Collects garbage
Lua base functions
(Help topic: lua=assert)
Enter a search string to find matching documentation.
Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.
Gammon Software support
Forum RSS feed ( https://gammon.com.au/rss/forum.xml )