print("******* Condition ******* ")
-- if 条件 then ... end
-- 但分支
a = 9
if a > 5 then
print("123")
end
-- 双分支
-- if 条件 then ....else 条件 then
if a < 5 then
print("123")
else
print("321")
end
-- 多分支
-- if 条件 then ....elseif 条件 then ... else ... ed
a = 213
if a < 5 then
print("123")
elseif a == 6 then
print("6");
elseif a == 7 then
print("7")
else
print("other");
end
a = 6
if a >= 3 and a <= 9 then
print("between 3 and 9")
end
-- Lua中没有switch语法,需要自己实现
Lua-- 条件语句
最新推荐文章于 2024-04-21 22:06:03 发布