system.expect
The expect module provides error checking functions for other libraries.
expect(index: number, value: any, ...: string): any
Check that a numbered argument matches the expected type(s). If the type doesn’t match, throw an error. This function supports custom types by checking the __name metaproperty.
Arguments
index
: The index of the argument to checkvalue
: The value to check...
: The types to check for
Return Values
value
field(tbl: any, key: any, ...: string): any
Check that a key in a table matches the expected type(s). If the type doesn’t match, throw an error. This function supports custom types by checking the __name metaproperty.
Arguments
tbl
: The table (or other indexable value) to search throughkey
: The key of the table to check...
: The types to check for
Return Values
The indexed value in the table
range(num: number[, min: number = -math.huge][, max: number = math.huge]): number
Check that a number is between the specified minimum and maximum values. If the number is out of bounds, throw an error.
Arguments
num
: The number to checkmin
: The minimum value of the number (inclusive) (defaults to -math.huge)max
: The maximum value of the number (inclusive) (defaults to math.huge)
Return Values
num