Afficher un message
Vieux 13/04/2008, 17h44   #9
Harald van Dijk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut 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.
  Réponse avec citation
 
Page generated in 0,04528 seconds with 9 queries