type( value )
- Returns the basic type of a given value as a string.
- value
-
- The value whose type to test.
The type()
function is similar to the corresponding Lua built-in function.
Examples[]
print(type(1)) -- "number"
print(type("hello")) -- "string"
print(type(false)) -- "boolean"
print(type({})) -- "table"
print(type(nil)) -- "nil"
print(type(print)) -- "function"
function print_is_number(v)
if type(v) == "number" then
print("it's a number")
else
print("it's not a number")
end
end