function iter(t) local i = 0 local n = table.getn(t) return function () i = i + 1 if(i <=n ) then return t[i] else return nil end end end ar = {1, 2, 3} ariter = iter(ar) while true do local e = ariter() if(e == nil) then break end print(e) end
lua迭代器示例
最新推荐文章于 2024-08-31 12:21:03 发布