lua中的分支结构
-
if 语句
me = {gender = "boy", age = 18, stature = 182}
if me.gender == "boy" and age == 18 then
print("handsome boy!!")
end-- 多分支 if me.gender == "boy" then print("handsome boy!!") elseif me.gender == "girl" then print("big old! big old! ORZ!") else print("made me feel pins and needles! ORZ! ORZ!!") end -- 分支嵌套 if me.gender == "boy" then print("handsome boy!!") if me.stature > 180 then print("so tall!!") end elseif me.gender == "girl" then print("big old! big old! ORZ!") else print("made me feel pins and needles! ORZ! ORZ!!") end
程序运行结果:
if语句的语法:
if [condition] then
[your coder logic]
end