function list_iter(t)
    local i = 0
    local n = table.getn(t)
    return function()
        i = i + 1
        if i <= n then return t[i] end
    end
end

t = {10, 20, 30}
iter = list_iter(t)
while true do
    local element = iter()
    if element == nil then break end
    print(element)
end

 

相关文章:

  • 2021-06-22
  • 2022-01-25
  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2021-10-01
  • 2021-09-04
  • 2022-01-09
猜你喜欢
  • 2021-06-28
  • 2021-12-12
  • 2021-11-11
  • 2021-10-31
  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案