I've been wondering how to use 'type' as I've seen people using it so much. For e.g:
if type then
--Do something
end
I've been wondering how to use 'type' as I've seen people using it so much. For e.g:
if type then
--Do something
end
Looks like you're having trouble googling that yourself, let me do that for you.
Type Function
In Lua, there is a function called ‘type’ that enables us to know the type of the variable. Some examples are given in the following code.
print(type("What is my type")) --> string
t = 10
print(type(5.8*t)) --> number
print(type(true)) --> boolean
print(type(print)) --> function
print(type(nil)) --> nil
print(type(type(ABC))) --> string
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Thanks alot!