Lua的elseif
和else if
有什么区别?我不知道它们是否相同而是更短。
x= 100
y= 100
if x > 90 then
...
else if y > 110 then
...
else
...
end
end
if x > 90 then
...
elseif y > 110 then
...
else
...
end
Lua没有else if
。
正确的语法是elseif
。
让我们来解决你的问题:
if x > 90 then
...
else
if y > 110 then
...
else
...
end
end
这有点复杂。这只有在你需要更多其他块的情况下才有意义。如果所有条件只有一个其他块,那么elseif就足够了。