Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Post-Increment Operator (int x = 5; x = x++;)

 
Brandon Lewis
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having trouble understanding the order of operations that happens in the following lines

Why does x still equal 5, and why does it seem to me that the post-increment operator is essentially being ignored?
 
Ganesh Patekar
Bartender
Posts: 696
23
Eclipse IDE Hibernate Java jQuery MySQL Database Netbeans IDE Oracle Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch!

In this topic <--- click here, you'll find an explanation for exactly the same question.

For more information another thread click here --->Order of evaluation
 
Brandon Lewis
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the reference!
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And in this topic you'll find another excellent explanation.
 
Brandon Lewis
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:And in this topic you'll find another excellent explanation.


I found this thread to be much more useful, thank you both for sharing!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic