Lua loop knowing when loops ends
loops, lua
Solution
This is simplified version of missingno's answer: :-)
for _, v in pairs(t) do
if next(t,_) == nil then
-- do something in last cycle
end
end
Problem
Is there a statement in Lua that would allow me to determinate whether it's last loop cycle? When I'm not able to determinate how many time loop will loop? Example: ``` for _, v in pairs(t) do if I_know_this_is_your_last_cycle then -- do something end ```