Re: Readability question.

"'Sainan' via lua-l" <[email protected]> Fri, 05 Jun 2026 11:08:19 +0000
Newsgroups gmane.comp.lang.lua.general
Message-ID <w41Z6X1LTaihVv-ObZgep0qzEZZEU1LOQevXAOs97jbe163V_iqISn_SN02CESJ2oG7XF8Aub5V_9GJwXQwCVDZf1d-K2DC9n4az4p8K6e8=@calamity.inc>
If you have to ask, it's probably not readable. I would make the conditional an actual conditional:

if a and b then
    x = combine(a, b)
else
    x = a or b
end

Now, one might also be able to see more obviously that if a=nil and b=nil then x=nil, so one could write `x = a or b or error()` in the else clause if that's undesired.

-- Sainan

-- 
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/w41Z6X1LTaihVv-ObZgep0qzEZZEU1LOQevXAOs97jbe163V_iqISn_SN02CESJ2oG7XF8Aub5V_9GJwXQwCVDZf1d-K2DC9n4az4p8K6e8%3D%40calamity.inc.