Lua
ivalue2333
He wept, for there were no more worlds to conquer.
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
lua-table使用笔记
参考:https://www.cnblogs.com/Dong-Forward/p/6063365.html 1:lua的table你可以先理解为既是一个数组也是一个字典 2:table判空 function isTableEmpty (t) if t == nil or next (t) == nil then return true else ...原创 2018-09-12 21:30:33 · 299 阅读 · 0 评论 -
lua--switch的语法实现
function test1() print("test1") print(test1) end function test2(val) print(val) end local switch = { test1 = test1, t2 = test2, } local t1 = switch["test1"] t1() print(t1) print("------") ...原创 2018-09-17 09:24:13 · 7679 阅读 · 0 评论 -
lua-深复制table
--categroty 工具方法 --src 源字符串 --dest 目标字符串 function _M.table_copy(src, dest) for k, v in pairs(src) do if type(v) == "table" then dest[k] = {} _M.table_copy(v,...原创 2018-09-17 11:55:19 · 1067 阅读 · 0 评论 -
Lua-Json解析的性能问题
1:环境 基于openresty建站 openresty版本1.11.2.5 LuaJIT 版本2.1.0 Luarocks版本2.4.4 通过Luarocks安装cjson()openresty官网说自带cjson模块,这个没有测试,反正我这里是通过Luarocks安装cjson。 2:解析Json 采用ngx.say输出json,在body_filter_by_lua_file中...原创 2018-09-06 10:23:44 · 2809 阅读 · 0 评论 -
lua-点号,冒号,self
1:self类似c++中的this指针,指向当前正在使用这个table的实例 2:”.”点号就是基本的table索引的方式 3:”:”冒号,记住一点就是省略self这个参数的作用,无论是在定义函数,还是在调用函数都是这个作用。冒号只能用于函数调用和定义,不能用于其他的情况 local mt = {} mt.num = 100 function mt.add_num(n) mt....原创 2018-09-13 10:05:14 · 276 阅读 · 0 评论 -
lua-ipairs, pairs遍历table
1:ua 5.3 手册 http://www.lua.org/manual/5.3/manual.html 2: ipairs (t) Returns three values: an iterator function, the table t, and 0, so that the construction for i,v in ipairs(t) do body end will...原创 2018-09-13 10:50:17 · 901 阅读 · 0 评论 -
lua-引用传递和值传递
function test1(tt) tt = {1, 3, 5} end function test2(tt) tt[1] = 2 tt["a"] = "hello" end t = {4, 5, 6} test1(t) for k,v in pairs(t) do print(v) end print("------") t = {4, 5, 6...原创 2018-09-27 14:01:06 · 6434 阅读 · 0 评论
分享