Jay Wolfe wrote:
Hi,
I came across this statement and it has a confusing element. I know the
whole '?:" construct and the assignment within the compare, but what's up
with the comma?
All the variables here are declared as doubles.
rtb = f < 0.0 ? (dx=x2-x1,x1) : (dx=x1-x2,x2)
Specifically, (dx=x2-x1,x1)? How do I read this?
The whole line is equivalent to:
if (f < 0.0)
{
dx = x2 - x1;
rtb = x1;
}
else
{
dx = x1 - x2;
rtb = x2;
}