Lua中是否有一条语句可以让我确定是否是最后一个循环周期?当我无法确定要循环多少个时间循环时?
例:
for _, v in pairs(t) do
if I_know_this_is_your_last_cycle then
-- do something
end
Run Code Online (Sandbox Code Playgroud)
这是missingno的答案的简化版本::-)
for _, v in pairs(t) do
if next(t,_) == nil then
-- do something in last cycle
end
end
Run Code Online (Sandbox Code Playgroud)