Re: Readability question.
"'Vadim' via lua-l" <[email protected]> Fri, 05 Jun 2026 11:50:23 +0000
| Newsgroups | gmane.comp.lang.lua.general |
|---|---|
| Message-ID | <[email protected]> |
>> If you have to ask, it's probably not readable. I would make the conditional an actual conditional: > >I ask because it is readable for me, but not sure how it is for others. This was the answer already :) I agree. To paraphrase the above: when in doubt, don't do it this way. I might have had the same temptation more than once. When you are used to this idiomatic construct, it's not a puzzle. Yet it ought to increase the cognitive load. Suddenly you have a lot going on in one line. It acts like a mental anchor, imho. Lines with variable assignment usually aren't doing logic and much side-effects. I would _generally_ prefer the visual structure of the obvious if-then-else when dealing with actual conditional expressions. Unless... you need to do a bunch of these calls throughout your code* and it remains readable despite real var names. * why not make it another function if this pattern is common? Cheers, Vadim -- 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/A6C9A64C-8BF5-42A4-BF24-7E28305070AC%40vad.cx.