Lua是动态类型语言,变量没有类型定义,每个变量都可以包含任何类型的值。
Lua的基本类型:boolean、number、string、userdata、function、thread、table
定义几个变量并查看他们的类型,如下:
testBool=true --boolean
testNum=12.3 --number
str="hello world" --string
p=print --print是lua的输出函数
tab={} --定义了一个空得table
使用type查看变量的类型:
print(type(testBool))
print(type(testNum))
print(type(str))
print(type(p))
print(type(tab))
(注:print为lua的输出函数)
输出:
boolean
number
string
function
table