Re: `if (!p ? i++ : 0) break;' == `if (!p){ i++; break;}' ?
On Sun, 13 Apr 2008 08:33:07 -0700, lovecreatesbea...@gmail.com wrote:
> On Apr 13, 10:57 pm, Eric Sosman <esos...@ieee-dot-org.invalid> wrote:
>> lovecreatesbea...@gmail.com wrote:
>> > Are the following two lines equal? Suppose the expression i++ doesn't
>> > overflow. They behave differently in my code.
>>
>> > if (!p ? i++ : 0) break;
>>
>> > if (!p){ i++; break;}
>>
>> They are not equivalent. Consider the case i==0.
>
> They may be equal when using prefix increment operator.
Then consider i == -1.
> The first case spans two lines but the latter occupies four lines,
As quoted here, both cases span one line.
|