Quote:
|
Originally Posted by NotQuiteFree
I figure using an if-then statement that says:
if(y > 5)
x = 1;
is easier to read and understand, than:
x = ((y > 5) ? 1 : 0);
|
Just as a warning, those aren't completely equilivant. For them to be the same, you should do:
Code:
if(y > 5)
x = 1;
else
x = 0;
Or:
Code:
x = 0;
if(y > 5)
x = 1;
Just pointing that out.
Personally, I think that the extra else clause is worth it in terms of readablitiy. When I'm reading other's code, I find it hard to spot terenary operators, as they are on one line and it is only noted by a : and a ?.
