[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: orif
- From: "Soni L." <fakedme@...>
- Date: Fri, 14 Aug 2015 17:56:26 -0300
On 14/08/15 05:02 PM, Patrick Donnelly wrote:
On Fri, Aug 14, 2015 at 1:55 PM, Soni L. <fakedme@gmail.com> wrote:
With orif:
```lua
local flag = false
if i == 1 then
flag = true
orif i == 2 then -- explicit fallthrough
print(flag)
else -- default
print "Unknown!"
end
```
Without commenting on the idea itself, I think "thenif" makes more
sense than "orif".
"thenif" makes it seem like an if inside an if.
"orif" is literally the "or" operator (can't stress this enough)
combined with "if".
It's similar to doing
local flag = false
local function f()
flag = true
end
if (i==1 and (f() or true)) or i==2 then -- (f() or true) is needed
because we always want it to be true)
print(flag)
else
print("Unknown!")
end
--
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.