Function of validation of input types of arguments to the function.
Last updated 1 year ago
Was this helpful?
.ArgAssert( value, argNum, expected, errorlevel )
The function is available by default in the gpm package environment, so just call ArgAssert instead of gpm.ArgAssert
Accept any type names from and custom type names created by .
function string.Mult( str, count) gpm.ArgAssert( str, 1, "string" ) gpm.ArgAssert( count, 2, "number" ) local output = "" for i = 1, count do output = output .. str end return output end print( string.Mult( "123", 5 ) ) -- 123123123123123 print( string.Mult( 123, 5 ) ) -- packages/fractions.lua:121: bad argument #1 to 'Mult' (string expected, got number)