User:OrenBochman/Lua Loops

LoopsEdit

Do BlockEdit

do
...
end

Do While LoopEdit

while cond do
...
end

Repeat LoopEdit

repeat
...
until cond


For Loop - NumericEdit

  • variable i is local to the loop block
for i = start, stop do
...
end

For Loop - GenericEdit

  • uses a keyword - in
  • variable i is local to the loop block
for i in iterator do
...
end
  • iterator is a function returning a list of remaining values. Standard iteritors are
    • Pairs
    • iPairs