Lua关键词
以下列出了Lua的关键词。保留关键字不能作为常量或变量或其他用户自定义标识符。
and | break | do | else |
elseif | end | false | for |
function | if | in | local |
nil | not | or | repeat |
return | then | true | until |
while | goto |
Lua数据类型
Lua是动态类型语言不需要类型定义。Lua中8个基本类型分别为:nil、boolean、number、string、userdata、function、thread和table。
Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio
> type("Hello World")
string
> type(2.5)
number
> type(nil)
nil
> type(print)
function
> type(false)
boolean
> type({key="value"})
table
> if 0 then print("0 is true") end
0 is true
> if not nil then print("nil is false") end
nil is false