inrange
function inrange( num, min, max ) --> res
Description
Checks if the number num is inside the with min and max defined number range. The number must be greater or equal min and lower or equal max.
Parameters
- min
-
The lower border for the number.
- num
-
The number that is checked.
- max
-
The upper border for the number.
Return Values
- res
-
true if num is greater or equal min and lower or equal max, otherwise false.
Code
--ZFUNC-inrange-v1 local function inrange( num, min, max ) --> res if num >= min and num <= max then return true else return false end end return inrange
Examples
local t = require( "taptest" ) local inrange = require( "inrange" ) local min = 2 local max = 11 t( inrange( 2, min, max ), true ) t( inrange( 7, min, max ), true ) t( inrange( 11, min, max ), true ) t( inrange( 1, min, max ), false ) t( inrange( 12, min, max ), false ) t()