mngnoq
Last Updated: February 25, 2016
·
1.337K
· alexanderbrevig
Feb007acc38e70d57f7b4c205f7e8b26

Post increment gotcha

Try to answer this without testing:

c=2;
c = 1 + c++;
// c = 3 or 4 ?

Compare it to:

c=2;
c = 1 + (++c);
// c = 3 or 4 ?

Finally:

c=[1,2,3];
i = 1;
c[i] = i++:
// c[1] = 1 or 2, or c[2] = 2 ?
Say Thanks
Respond

1 Response
Add your response

421
Thumb alyssa pohahau

i enjoyed this brain exercise! a very original tip -- kudos.

over 1 year ago ·