# Operators & Assignments

N Rao
Greenhorn
Posts: 14
Hi friends,
please help, might be a basic doubt but I really find it tricky.

Given the following:

In the above snippet, please note that Set-1 changed the value of i (from 10 to 11). But Set-2 didnot (i stays at 11), while Set-3 did (from 11 to 12) and never again did the value of i change.

Can you please explain the above phenomenon? May be I am ignoring some basic rule or may be it is an anomaly? Kindly explain!

cheers,
Nanjunda

Jeroen Wenting
Ranch Hand
Posts: 5093
i = i++; doesn't actually change the value of i at all. It's a dummy operator.
What happens is

Serge Plourde
Ranch Hand
Posts: 140
Hi Rao,

In this code snippet, you must first see what is the result of the expression at the right side of the equal sign, then assign it to i.

N Rao
Greenhorn
Posts: 14
That was great!

Thanks a lot, Jeroen and Serge for your explanations that helped me understand this more clearly.

cheers,
N Rao

Corey McGlone
Ranch Hand
Posts: 3271

N Rao
Greenhorn
Posts: 14
Hi Corey,
That was an interesting site indeed!

I already learnt few new things out there.

Thanks a lot for that!

Cheers,
~NRao