Afficher un message
Vieux 14/04/2008, 00h47   #15
Peter Nilsson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: `if (!p ? i++ : 0) break;' == `if (!p){ i++; break;}' ?

Willem 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;}
>
> Nope. This, however, should be equal to the first:
>
> if (!p) { if (i++) break;}


Not if there's an 'else' attached to the first 'if', particularly if
p == 0 and i == 0. If you include an 'else', then it's generally
only equivalent to:

if (!p && i++) break;

--
Peter
  Réponse avec citation
 
Page generated in 0,05516 seconds with 9 queries