📜  在范围循环中 - Lua 代码示例

📅  最后修改于: 2022-03-11 14:54:55.643000             🧑  作者: Mango

代码示例1
-- In range loops are really easy to make.
-- It does not require pairs() or ipairs(), those are table iterations.

-- A in range loop is exactly as is:
for variable in 10 do
    print(variable)
    variable = variable + 1
end

-- If the above block fails it's purpose, the bottom block is a replacement.
for variable = 0, 1, 1 do
    print(variable)
    variable = variable + 1
end