📜  lua 如何进行循环 - Lua 代码示例

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

代码示例4
-- for in/for loops
for key, value in pairs(table) do
    -- If value is a table then you can do another iteration tho, for in for in isn't recommended.
end

for key, value in next, table do
    -- Same as above.
end

for variable = 0, 1, 1 do
    -- The variable is automatically set to the first value you input after "=".
    -- The variable is then incremented by the third value you input after "="
    -- until it reaches the second value you input after "=".

    variable = variable + 1 -- The above only works if you increment it,
    -- else it infinitely loops through the block.
end

while true do
    -- Infinite loop
end