if/else
单个 if 分支 型
x = 10
if x > 0 then
print("x is a positive number")
end两个分支 if-else 型
x = 10
if x > 0 then
print("x is a positive number")
else
print("x is a non-positive number")
end多个分支 if-elseif-else 型
score = 90
if score == 100 then
print("Very good!Your score is 100")
elseif score >= 60 then
print("Congratulations, you have passed it,your score greater or equal to 60")
--此处可以添加多个elseif
else
print("Sorry, you do not pass the exam! ")
endLast updated