Assert()

From Riftui Wiki

Jump to: navigation, search

Ensures condition is true. Basically it is built-in implementation of

function assert(condition, message, ...)
    if (not condition) then
        error(message);
    end
 
    return condition, message, ...;
end

Contents

Signature

assert(condition [, message])

Parameters

condition (boolean) - if false, throws error

message (string, default = "assertion failed.") - error message to be thrown when condition is false

Return value

This function returns all given parameters

Notes

Lua accepts any value as boolean, everything except 'false' and 'nil' will be treated as 'true'

Examples

assert(true); -- nothing happens
assert(false); -- throws "assertion failed."
 
assert(true, "'true' is not true"); -- nothing happens
assert(false, "'false' is false"); -- throws "'false' is false."
Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox