3 ms·
I think the accepted answer should be Eren Ersönmez's. Comparing if (i > 0) { value += 2; } else {
by cocoflunchy 13y ago
I think the accepted answer should be Eren Ersönmez's.
Comparing
if (i > 0)
{
value += 2;
}
else
{
value += 3;
}
Is not the same as
value += i > 0 ? 2 : 3;
Quoting the answer:
In one case, you create two different += operations with constant values and which one you
pick depends on a condition, and in the other case, you create a += where the value to add
depends on a condition.