摘要: 运算符重载: __add: tbl = setmetatable({ 1, 2, 33 }, { __add = function(tbl, v) -- tbl 的长度不断变化, table.insert的pos参数不能使用#tbl+1, 越界会产生 position out of bounds i 阅读全文
posted @ 2022-05-29 23:26 ascertain 阅读(24) 评论(0) 推荐(0) 编辑
摘要: function producer() local i = 0 print(coroutine.running()) while true do i = i + 1 if i > 5 then error('out of number') end print('In Producer>> corou 阅读全文
posted @ 2022-05-29 17:46 ascertain 阅读(23) 评论(0) 推荐(0) 编辑
摘要: repeat unitl 先执行循环体, 满足until条件时退出 for 阅读全文
posted @ 2022-05-29 12:59 ascertain 阅读(28) 评论(0) 推荐(0) 编辑
摘要: 一维数组 模拟 二维数组 array = {} rows = 3 cols = 4 for row = 1, rows do for col = 1, cols do array[(row - 1) * cols + col] = row * col end end for row = 1, row 阅读全文
posted @ 2022-05-29 00:12 ascertain 阅读(39) 评论(0) 推荐(0) 编辑