views:

72

answers:

1

Hi All,

This is probably a really basic syntax question, but I can't find the answer.

Can anyone tell me what this expression means?

objPoint.x = -objPoint.x; 

As a note, objPoint is a CGPoint

Thanks!

+2  A: 

You change the horizontal coordination to its negative.

Another example is that:

x = 7;
x = -x;

Then it will become x = -7;

This is the evaluation process:

The evaluation process will be ran in the right hand side first, so the process is:

replace x with 7, the right hand side of -x will become -7.

then assign it to the left hand side: x = -7;

vodkhang
thanks, I must be exhausted to not have realized that!
GL777
Thanks for some editting, but I mean because x = 7 so -x = - (7)
vodkhang
What does that last statement return? What does `(-7 == (-x = -(7)))` evaluate to? I'm assuming true, since it will do the assignment then evaluate the expression. Also, will `(-x) = (-7)` compile?
Jamie Wong
No, I mean for the expression x = -x, first, the computer will replace x by 7 so the right hand side will become -7. That's what it means for -x = -7
vodkhang