This first edition was written for Lua 5.0. While still largely relevant for Lua 5.1, there are some differences.
The second edition targets Lua 5.1 and is available at Amazon and as an e-book.
By buying the book, you also help to support the Lua project.


4.3.2 – while

As usual, Lua first tests the while condition; if the condition is false, then the loop ends; otherwise, Lua executes the body of the loop and repeats the process.

    local i = 1
    while a[i] do
      print(a[i])
      i = i + 1
    end