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 ?
Written by Alexander Brevig
Related protips
1 Response
i enjoyed this brain exercise! a very original tip -- kudos.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Csharp
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#