另一种写法

控制流 / 条件语句 / if/else 语句

local latitude = -42

-- 括号可以加,但不是必需的
local location
if (latitude == 0) then
  location = "Equator"
elseif (latitude < 0) then
  location = "Southern Hemisphere"
else
  location = "Northern Hemisphere"
end
-- location = Southern Hemisphere

-- 整个 if 写在一行
local sign = "+"
if latitude < 0 then sign = "-" end
-- sign = -

-- else if 会打开一个嵌套的 if,它有自己的 end
local side
if latitude == 0 then
  side = "none"
else
  if latitude < 0 then
    side = "south"
  else
    side = "north"
  end
end
-- side = south

print("location = " .. location)
print("sign = " .. sign)
print("side = " .. side)