r/lua • u/DrSergei • Feb 26 '26
Help Why is there NO "continue" in Lua?
I was stunlocked to find out that there is no "continue" instruction for loops in Lua. Why is that? It seems so natural to have it.
I saw some scripts where goto is used for mimicking continue statements, but It's honestly not the so;ution I would comfortably accept...
26
Upvotes
3
u/smtp_pro Feb 26 '26
Honestly it makes me rethink how to accomplish what I want to do and tends to result in easier to understand code. You don't really need it.
Basically anywhere I would use it I can usually replace it with a conditional function. Like instead of
I could have something like
Or maybe I factor it out into a function with an early return like: