Lua语言中的if-else控制结构很简单明了。
local x=10
if x>=10 then
print('x>=10')
else
print('x<10')
end
local y=20
if y==20 then
print('y==20')
elseif y>20 then
print('y>=20')
else
print('y<20')
end
注意:
如果把elseif折开写,则相当于是在else代码块中嵌套另一个if语句。
local z=10
if z==10 then
print('z==10')
else
if z>0 then
print('z>0')
end
end
閱讀更多 網絡圈 的文章