Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Why does return count++ not work here
count ++ is the same as count +1 and count +=1 or am I going crazy today!?
Steven Parker210,144 Points
The "++" operator is known as a "post-increment", which means that it returns the current value first, and then increments it.
So when it appears on a line by itself, it does the same thing as the other examples. But when you do something directly with the value (like in a "return") you get a different value.
You didn't show the actual code, but unless "count" is a global, you probably want "
count + 1" there.