Lets say i have a loop like this
for i = 1, 3 do
print(i)
end
--output
-- 1
-- 2
-- 3
what i want is to not print the second time like this:
for i = 1, 3 do
if i == 2 then
--something that prevents the code from going further
end
--if i is 2 then this wont happen
print(i)
end
-- output
-- 1
-- 3
this would be similar to returning nothing in a function
stay = true
function someFunction()
print("Hello world!")
if stay == true then return end
--further code will not run
print("Goodbye world!")
end
there is a solution to this, but i dont like the extra indentation and would like to know if there is a way to do this without the extra indentation
(solution with extra indentation)
for i = 1, 3 do
if i ~= 2 then
print(i)
end
end
-- output
-- 1
-- 3