Lua Programming/How to Lua/type

From Wikibooks, open books for an open world
Jump to: navigation, search

The type function gives the datatype name of a given value[edit]

print(type("banana"))    -- returns "string"
print(type(3.5))         -- returns "number"
print(type(true))        -- returns "boolean"
print(type(print))       -- returns "function"
print(type(nil))         -- returns "nil"