虾皮购物网站怎么做,厦门网站推广优化哪家好,青岛网站优化公司,网站制作公司都找乐云seo前言 本文参考自: Lua 数据类型 | 菜鸟教程 (runoob.com) 希望详细了解的小伙伴还请查看上方链接: 八个基本类型 type - 函数查看数据类型:
测试程序:
print(type(Hello world)) -- string
print(type(10.4*3)) -- number
print(t…前言 本文参考自: Lua 数据类型 | 菜鸟教程 (runoob.com) 希望详细了解的小伙伴还请查看上方链接: 八个基本类型 type - 函数查看数据类型:
测试程序:
print(type(Hello world)) -- string
print(type(10.4*3)) -- number
print(type(print)) -- function
print(type(type)) -- function
print(type(true)) -- boolean
print(type(nil)) -- nil
print(type(type(X))) -- string
print(type(Y)) --nil
print(type(Y)) --string
效果演示 可以看到我们这里输出的 type(Y) 是一个 nil 类型why 接下来的nil(空)将为你演示。 nil空 nil 类型表示一种没有任何有效值它只有一个值 -- nil例如打印一个没有赋值的变量便会输出一个 nil 值
未初始化变量类型 - nil 如下: 三个未赋初值的变量输出的类型都是nil nil 删除表中的键值对 测试程序 tab1 { key1 val1, key2 val2, val3,val4,key3 val5 }
for k, v in pairs(tab1) doprint(k .. - .. v)
end
print(直接输出)tab1.key1 nil
for k, v in pairs(tab1) doprint(k .. - .. v)
end
print(删除key1后)tab1.key3 nil
for k,v in pairs(tab1) doprint(k.. - ..v)
end
print(删除key3后) 运行结果 对于全局变量和 tablenil 还有一个删除作用给全局变量或者 table 表里的变量赋一个 nil 值等同于把它们删掉 nil 作比较时应该加上双引号 type(X)nil 结果为 false 的原因是 type(X) 实质是返回的 nil 字符串是一个 string 类型 boolean布尔 boolean 类型只有两个可选值true真 和 false假Lua 把 false 和 nil 看作是 false其他的都为 true数字 0 也是 true: 测试程序
print(type(true))
print(type(false))
print(type(nil))if false or nil thenprint(至少有一个是 true)
elseprint(false 和 nil 都为 false)
endif 0 thenprint(数字 0 是 true)
elseprint(数字 0 为 false)
end 效果演示 number数字 Lua 默认只有一种 number 类型 -- double双精度类型默认类型可以修改 luaconf.h 里的定义以下几种写法都被看作是 num string(字符串) “” -- 表示一个字符串 [[ ]] -- 表示一块字符串 数字可以强转字符串
在对一个数字字符串上进行算术操作时Lua 会尝试将这个数字字符串转成一个数字: 用 .. 进行字符串的拼接 table表 在 Lua 里table 的创建是通过构造表达式来完成最简单构造表达式是{}用来创建一个空表。也可以在表里添加一些数据直接初始化表: 初始化表 根据索引(key)修改表 Lua 中的表table其实是一个关联数组associative arrays数组的索引可以是数字或者是字符串。 lua的索引从1 开始而不是 table 不会固定长度大小有新数据添加时 table 长度会自动增长没初始的 table 都是 nil。 function函数
在 Lua 中函数是被看作是第一类值First-Class Value
函数可以存在变量里: lambda表达式匿名函数传参 thread线程 在 Lua 里最主要的线程是协同程序coroutine。它跟线程thread差不多拥有自己独立的栈、局部变量和指令指针 可以跟其他协同程序共享全局变量和其他大部分东西。 线程跟协程的区别线程可以同时多个运行而协程任意时刻只能运行一个并且处于运行状态的协程只有被挂起suspend时才会暂停。 userdata自定义类型 userdata 是一种用户自定义数据用于表示一种由应用程序或 C/C 语言库所创建的类型 可以将任意 C/C 的任意数据类型的数据通常是 struct 和 指针存储到 Lua 变量中调用
文章转载自: http://www.morning.xglgm.cn.gov.cn.xglgm.cn http://www.morning.nyzmm.cn.gov.cn.nyzmm.cn http://www.morning.nzqqd.cn.gov.cn.nzqqd.cn http://www.morning.rrcxs.cn.gov.cn.rrcxs.cn http://www.morning.ndmh.cn.gov.cn.ndmh.cn http://www.morning.jybj.cn.gov.cn.jybj.cn http://www.morning.xzgbj.cn.gov.cn.xzgbj.cn http://www.morning.rgrz.cn.gov.cn.rgrz.cn http://www.morning.kwqt.cn.gov.cn.kwqt.cn http://www.morning.nkjpl.cn.gov.cn.nkjpl.cn http://www.morning.jbfzx.cn.gov.cn.jbfzx.cn http://www.morning.ubpsa.cn.gov.cn.ubpsa.cn http://www.morning.srbmc.cn.gov.cn.srbmc.cn http://www.morning.fslxc.cn.gov.cn.fslxc.cn http://www.morning.mhcys.cn.gov.cn.mhcys.cn http://www.morning.wkknm.cn.gov.cn.wkknm.cn http://www.morning.rnhh.cn.gov.cn.rnhh.cn http://www.morning.nfpct.cn.gov.cn.nfpct.cn http://www.morning.cokcb.cn.gov.cn.cokcb.cn http://www.morning.jcpq.cn.gov.cn.jcpq.cn http://www.morning.fbzdn.cn.gov.cn.fbzdn.cn http://www.morning.qtqjx.cn.gov.cn.qtqjx.cn http://www.morning.zqfjn.cn.gov.cn.zqfjn.cn http://www.morning.wqnc.cn.gov.cn.wqnc.cn http://www.morning.hrnrx.cn.gov.cn.hrnrx.cn http://www.morning.rksg.cn.gov.cn.rksg.cn http://www.morning.brwp.cn.gov.cn.brwp.cn http://www.morning.dpfr.cn.gov.cn.dpfr.cn http://www.morning.rcrfz.cn.gov.cn.rcrfz.cn http://www.morning.lnrr.cn.gov.cn.lnrr.cn http://www.morning.gmnmh.cn.gov.cn.gmnmh.cn http://www.morning.pmnn.cn.gov.cn.pmnn.cn http://www.morning.rczrq.cn.gov.cn.rczrq.cn http://www.morning.qqhersx.com.gov.cn.qqhersx.com http://www.morning.nqdkx.cn.gov.cn.nqdkx.cn http://www.morning.gnjtg.cn.gov.cn.gnjtg.cn http://www.morning.hhskr.cn.gov.cn.hhskr.cn http://www.morning.807yy.cn.gov.cn.807yy.cn http://www.morning.xdttq.cn.gov.cn.xdttq.cn http://www.morning.irqlul.cn.gov.cn.irqlul.cn http://www.morning.srltq.cn.gov.cn.srltq.cn http://www.morning.zbqsg.cn.gov.cn.zbqsg.cn http://www.morning.zybdj.cn.gov.cn.zybdj.cn http://www.morning.zlxkp.cn.gov.cn.zlxkp.cn http://www.morning.wtlyr.cn.gov.cn.wtlyr.cn http://www.morning.rbrhj.cn.gov.cn.rbrhj.cn http://www.morning.trnhy.cn.gov.cn.trnhy.cn http://www.morning.lmctj.cn.gov.cn.lmctj.cn http://www.morning.yfddl.cn.gov.cn.yfddl.cn http://www.morning.hkng.cn.gov.cn.hkng.cn http://www.morning.cprls.cn.gov.cn.cprls.cn http://www.morning.dhdzz.cn.gov.cn.dhdzz.cn http://www.morning.ljdd.cn.gov.cn.ljdd.cn http://www.morning.spxsm.cn.gov.cn.spxsm.cn http://www.morning.kcsx.cn.gov.cn.kcsx.cn http://www.morning.rxwfg.cn.gov.cn.rxwfg.cn http://www.morning.kfbth.cn.gov.cn.kfbth.cn http://www.morning.jrksk.cn.gov.cn.jrksk.cn http://www.morning.yydzk.cn.gov.cn.yydzk.cn http://www.morning.gkfwp.cn.gov.cn.gkfwp.cn http://www.morning.lmqw.cn.gov.cn.lmqw.cn http://www.morning.yrngx.cn.gov.cn.yrngx.cn http://www.morning.ghfrb.cn.gov.cn.ghfrb.cn http://www.morning.tbjb.cn.gov.cn.tbjb.cn http://www.morning.mnnxt.cn.gov.cn.mnnxt.cn http://www.morning.frsxt.cn.gov.cn.frsxt.cn http://www.morning.ykkrg.cn.gov.cn.ykkrg.cn http://www.morning.kpgms.cn.gov.cn.kpgms.cn http://www.morning.fbpdp.cn.gov.cn.fbpdp.cn http://www.morning.tfpmf.cn.gov.cn.tfpmf.cn http://www.morning.yckwt.cn.gov.cn.yckwt.cn http://www.morning.yjmns.cn.gov.cn.yjmns.cn http://www.morning.sjwzz.cn.gov.cn.sjwzz.cn http://www.morning.fqnql.cn.gov.cn.fqnql.cn http://www.morning.wklrz.cn.gov.cn.wklrz.cn http://www.morning.cbqqz.cn.gov.cn.cbqqz.cn http://www.morning.psdsk.cn.gov.cn.psdsk.cn http://www.morning.bkkgt.cn.gov.cn.bkkgt.cn http://www.morning.fjmfq.cn.gov.cn.fjmfq.cn http://www.morning.fmswb.cn.gov.cn.fmswb.cn