您的位置:首页 > 编程语言 > Lua

Lua基本语法

2015-07-03 09:54 549 查看
1、Lua中的变量类型有:

a = 1 --number

b = "abc" --string

c = {} --table

d = print -- function

e = true --bool

2、Lua变量名大小写敏感,不要以_开头,这些都表示一些特殊变量

3、关键字: and、beak、do、else、elseif、end、false、for、function、if、in、local、nil、not、or、repeat、return、then、true、until、while

4、string类型的字面值有:“”、‘’、和多行字符串[[ ]]三种

5、Lua允许多个变量同时赋值,例如: a,b = 1,2 a,b = b,a表示交换两个变量

6、输出到console的方式: print("hello world")、 io.write("hello world")

t = {name = "kylin", age = 18, gender = "male"} -- 此为一个table类型的变量





内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: