Information générale
Catégorie:
Code, syntaxe and commandes
Versions des environnements
>>I think the documentation states that in these cases i is only evaluated once for the line. Given that the results will be as found.
>>e.g i += ++i; // 3 not 4
>>Best,
>>Viv
>
>
>Viv,
>
>Guess I was looking for side effects
>
>If I understand the definition of 'evaluated', then it will be evaluated twice in the example above since it's referenced twice on the right hand side
>i += ++i becomes i = i + ++i
No. Evaluated once per line not once per reference.
Given, say i=3 then
i += ++i;
would be equivalent to:
3 += ++3;
(I know you can't use the operators in this way - but you see what I mean)
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement