Why does Lua have no “continue” statement?

后端 未结 11 1686
无人及你
无人及你 2020-12-07 13:23

I have been dealing a lot with Lua in the past few months, and I really like most of the features but I\'m still missing something among those:

  • Why is there no
11条回答
  •  -上瘾入骨i
    2020-12-07 14:19

    We can achieve it as below, it will skip even numbers

    local len = 5
    for i = 1, len do
        repeat 
            if i%2 == 0 then break end
            print(" i = "..i)
            break
        until true
    end
    

    O/P:

    i = 1
    i = 3
    i = 5
    

提交回复
热议问题