Like this thread, but only focusing on the continue
keyword.
continue
is not present in Vanilla Lua, however it proves to be extremely useful in loops and its applications, having been added into so many numerous languages like;
- C family languages (C/C#/C++)
- JavaScript
- Java
- Python
- Visual Basic
- etc
The keyword is used like this;
for i = 1, 10 do
if i % 2 == 1 then
continue
end
print(i)
end
Like with break
. This prints every even number from 1-10.
This is just an example on its syntax, not an actual usage case.
As a Roblox developer, I find consistent needs to use continue
. continue
is useful for many applications. An example is data get retries; where if it fails, it can continue
the loop to retry the data and keep going, instead of trying to rely on break
, being confused in the process, or writing unnecessary lines. continue
allows developers to have more flexibility when writing code concerning loops and why does Lua not have it?
What doesn’t make sense is that Lua has break
, but not continue
. The languages I listed above that has continue
, has break
as well. Why does Rbx.Lua, being based off of vanilla Lua, has break
but decide not to add continue
? I understand it may be hard for Roblox to perhaps change Rbx.Lua’s internal functions, and even implement the case itself, nevertheless has a wide range of use cases.
“There’s nothing “clear enough” about writing code without continue. It’s a novice mistake to nest code inside a conditional where a continue should have been used, and the need to write ugly code like that shouldn’t receive any sympathy. There’s absolutely no excuse.” – Glenn Maynard Sep 12 '15 at 23:56
(a reply found from the topmost answer in the StackOverflow linked)
It will be very helpful for Roblox developers if this feature can be considered.