lua初学笔记

print(“hello world”)
–单行注释
–[[
多行注释
变量:字母,数字,下划线, _A @ $ 区分大小写

lua关键字
逻辑运算符:and or not
条件运算符:> < == ~= <= >=
算术运算符:+ - * / %
if…then…else…end if…then…elseif…end
function … end
for…do…end
while…end
repeat…until
in
true false
local nil
i+=1 i++(错误)
]]–
–lua 八大数据类型
–nil boolean number string
–userdata function therad table

–lua所定义的变量默认是全局变量,定义局部变量需要关键字local

–nil:没有任何有效值
–a=nil
print(type(a))
a=1
a=2
print(a)
–用来做删除
a=nil
print(a)

–boolean
–lua把"false"和"nil"认为是false,其他的都为true
print(type(true))
print(type(false))
print(type(nil))

if 0 then
print(“为真”)
end

–number:数字 默认是double类型
print(type(2))
print(type(2.1))
print(type(2.13546489465489415414))
print(type(2e+1))

–string:字符串:由一对双引号或者单引号来表示
string=“abc”
string2=‘abc’
string3=‘a’
print(type(string))
print(type(string2))
print(type(string3))
print(‘2’+6) --8 数字字符串类型自动转换成了数字类型
print(“2”+‘6’) – 8
–print(“error”+2) --报错
print(“error”…2)–字符串拼接
print(#string)–#计算字符串长度

–userdata:用户自定义类型
–将任意c/c++/c#的数据类型存储到lua变量中调用

–thread 线程

–function

–table

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值