[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Added `continue` keyword to Lua 5.4 [code review requested].
- From: Steven Hall <shallnot@...>
- Date: Fri, 17 Mar 2023 14:48:06 +0000
I’ve found that if-statement nesting can be easily removed by re-evaluating (refactoring if you want a better buzz-word) your logic.
You might want to come up with a more convoluted example as one can eliminate the “continue” easily here and many other such trivial examples.
for i = 1, 10 do
if i % 2 ~= 0 then print (i) end
end
> for i = 1, 10 do
> if i % 2 == 0 then continue end
> print( i )
> end
>
> This should really help to reduce unnecessary if-statement nesting inside loops.