尧图精选

【2014-08-28】Lua快速学习笔记:值与类型

🕒 发布时间:2026/9/1 7:27:11 📁 来源:尧图网络
[历史归档]本文原发布于 cstriker1407.info 个人博客内容为历史存档仅供参考。发布时间2014-08-28 标题Lua快速学习笔记值与类型分类编程 / C C / Lua 标签luaLua快速学习笔记值与类型备注注释变量类型关于bool值字符串字符串操作备注1 本笔记只记录了LUA的一小部分内容对于LUA的描述并不全面以后随用随增加吧。2 本笔记参考《Lua程序设计 第二版》截图和代码属于原作者所有。3 作者初学LUA经验和能力有限笔记可能有错误还请各位路过的大牛们给予指点。注释-- this is commment--[[ this is commment --]]注意这里的的数目需要相等--[[ this is commment --]]变量访问未定义变量返回nil。print(x);--输出nilx10;print(x);--输出10xnil;类型关于bool值字符串LUA的字符串是不可变的值LUA修改字符串会创建一个新的字符串。LUA能够高效的处理长字符串。关于单双引号以下代码均可正确输出strHello World;print(str);strHello World;print(str);strHello test World;print(str);strHello test World;print(str);strHello test1 \test2\ World;print(str);strHello \test1\ test2 World;print(str);strHello \test1\ \test2\ World;print(str);strHello \test1\ \test2\ World;print(str);输出一段字符串这里会精确的输出里面的所有内容忽略其中的转义序列str[[ aa; bb; test1; test2; \test1\; \test1\; ]];print(str);输出为aa;bb;test1;test2;\test1\;\test1\;输出一段含有[[]]的字符串str[[ --this is commment1 --[[ this is commment2 --]] [[ ]] [[ ]] ]];print(str);输出--this is commment1--[[ this is commment2 --]][[ ]][[ ]]字符串操作…字符串连接符#获取字符串长度操作符strHello World;print(str.. length:..#str);--输出 Hello World length:11
上一篇/下一篇内容由系统自动关联 返回资讯列表 →