lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Aug 14, 2015 at 3:01 PM, Soni L. <fakedme@gmail.com> wrote:
> orif is the or operator combined with elseif.
>
> It's similar to this (if Lua allowed this):
>
> local flag = false
> if i == 1 then
>   flag = true
>   goto next
> elseif i == 2 then
>   ::next::
>   print(flag)
> else
>   print"Unknown!"
> end

This can be written in stock Lua without any new features by using
nested if blocks:

local flag = false
if i == 1 or i == 2 then
  if i == 1 then
    flag = true
  end
  print(flag)
else
  print"Unknown!"
end