July 2018
Beginner
202 pages
5h 42m
English
There is one very important function built into Lua, type. This function will return the type of a variable as a string. Let's take a look at this function in action:
var1 = truevar2 = 3.145var3 = nilvar4 = type(var1)var5 = type(type(var2))print (type(var1)) -- booleanprint (type(var2)) -- numberprint (type(var3)) -- nilprint (var4) -- booleanprint (var5) -- string
Because the type function returns a string, the result can be assigned to a variable, like so:
var4 = type(var1)
Or, the result can be passed directly to a function such as print, like so:
print (type(var1))
The type of the type of something type(type(var2)), as represented by var5, will always be a string. This is because, as stated before, type returns a string. ...