1. 程式人生 > >Lua中的條件判斷

Lua中的條件判斷

if...elseif....else...end,這是lua中的條件判斷語句。

-- if (條件)  then
--   ...
-- elseif (條件)  then
--   ...
-- else
--   ...
-- end


n = 10
if (n==1)  then
    print (1)
elseif (n==5) then
    print (5)

else
    print ('hehe')
end
>>
hehe