[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: if-else
- From: frank <frank@...>
- Date: Tue, 13 Apr 2010 01:00:44 +0200
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