449
got him (lemy.lol)
submitted 6 months ago by ngn@lemy.lol to c/programmerhumor@lemmy.ml
you are viewing a single comment's thread
view the rest of the comments
[-] SpaceNoodle@lemmy.world 3 points 6 months ago* (last edited 6 months ago)

(p += 1) resolves to the value of p after the incrementation, as does ( p = p + 1).

[-] fluckx@lemmy.world 2 points 6 months ago

Yes.

p++ == p+= 1 == p = p + 1 are all the same if you use it in an assignment.

++p is different if you use it in an assignment. If it's in its own line it won't make much difference.

That's the point I was trying to make.

[-] SpaceNoodle@lemmy.world 5 points 6 months ago

No.

++p returns incremented p.

p += 1 returns incremented p.

p = p + 1 returns incremented p.

p++ returns p before it is incremented.

[-] fluckx@lemmy.world 3 points 6 months ago

Right. So i had them the other way around. :D

Thanks for clarifying.

this post was submitted on 09 May 2024
449 points (92.3% liked)

Programmer Humor

32410 readers
341 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS