Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

++

 
Miran Cvenkel
Ranch Hand
Posts: 177
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
out of curiosity:



I get out 0, but then again i have no idea how that work at all.
Next:

gives me 1.

I would expect 1 in first case.

as it looks now:

would give same thing at start, but the code is different.



Any thought about that ?
 
Stuart James
Greenhorn
Posts: 4
  • 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I am understanding your question correctly, the first call to out.Print gives 0 because you have used the postfix increment operator - the value of c is printed, then incremented.

If you want to see 1 in the first call you need to use the prefix increment operator (++c). Then the value is incremented prior to printing.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
+1 for the subject.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To summarize it with code:

 
Campbell Ritchie
Sheriff
Pie
Posts: 47293
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This question arises frequently. We have an FAQ about it.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic