跳到主內容

【Lua】【流程控制】if

 

if true then
  print("if block")
elseif true then
  print("elseif block")
else
  print("else")
end
if not true then
  print("not true")
else
  print("else")
end

elseif 中間沒有空白要注意

if true then
  print("if block")
else if true then
  print("elseif block")
else
  print("else")
end
end

-- 其實等於

if true then
    print("if block")
else 
    if true then
        print("elseif block")
    else
        print("else")
    end
end