Re: Replacing the "if" statement with an "if" expression which supersedes it

Paul K <[email protected]> Fri, 26 Jun 2026 09:50:34 -0700
Newsgroups gmane.comp.lang.lua.general
Message-ID <CADUw5q0pqcECiUD2Y8m+4BV1pyrsJHZ364jzksKx-jecTU5C3Q@mail.gmail.com>
Hi Calimero,

On Fri, Jun 26, 2026 at 8:44 AM 'Calimero' via lua-l
<[email protected]> wrote:
> Le 26/06/2026 à 17:32, Andrey Dobrovolsky a écrit :
> > (10 < 11) and ("yes") or ("no")
> yes
> > (10 < 11) and (false) or (0)
> 0
>
> Can you fix the second example to return `false` as it should, by adding some parentheses? I experimented but failed.

I usually just negate the condition when I run into this situation:

> not(10 < 11) and (0) or (false)
false

Paul.

-- 
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/CADUw5q0pqcECiUD2Y8m%2B4BV1pyrsJHZ364jzksKx-jecTU5C3Q%40mail.gmail.com.