lua-users home
lua-l archive

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




On 14/08/15 04:08 PM, Jonathan Goble wrote:
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

But now you check for the condition twice.

--
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.