Does using return in a while loop cause it to stop looping?
1 Like
Yes, but unless you’re actually trying to return something you should just use break
1 Like
I don’t want to stop the loop that’s the issue, i just want it to return to the beginning.
1 Like
If you want to skip an iteration you can use the continue keyword.
2 Likes
Like what the person above me said, you can use continue. Here is an example:
local t = {"a", "b", "c", "d", "e"}
for i, v in pairs(t) do
if i == 3 then
continue -- when it reaches the 3rd value in the table, it will stop the iteration and not execute the instruction underneath.
end
print(v)
--[[
11:07:08.849 a - Edit
11:07:08.849 b - Edit
11:07:08.850 d - Edit
11:07:08.850 e - Edit
]]
end
1 Like
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.