Hello! Recently I started playing with new lua version, and I came across usefull things - goto statements.
If you are familiar with assembler labels they are familiar, yet in lua it is much more restricted.
However you can make a nice structures with it, that simply were not avaible without this.
Take a look at this example:
To try it out, you would need to compile independent lua 5.2 interpreter, or make few changes to use it inside your engine, cheers
If you are familiar with assembler labels they are familiar, yet in lua it is much more restricted.
However you can make a nice structures with it, that simply were not avaible without this.
Take a look at this example:
Code:
for i = 0, 10 do
::redo:: --defining a label
if i%2==0 then
print("Continue "..i)
goto continue--We skip a code to continue label (at the end of the loop)
end
print("Regular")
::continue::
end
To try it out, you would need to compile independent lua 5.2 interpreter, or make few changes to use it inside your engine, cheers