lua-users home
lua-l archive

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


Sam Roberts wrote:
What's the easiest translation to convert the following c to lua? or do I
have to make this into a if-else block.

x = ((vXSTX > vXSX) || (vXSTX > vXSY)) ? (vXSX + vXSTX) : vXSX;

x = ((vXSTX > vXSX) or (vXSTX > vXSY)) and (vXSX + vXSTX) or vXSX

This is the surely the most compact translation.

But if someone asks for the easiest translation of a one-line code
snippet, should you give them the ol' short circuit trickery, or do
you consider they might be better off with something less compact,
and more... easy and transparent?

Probably better to go for if-else.

Regards, Frank