ngn@lemy.lol to Programmer Humor@lemmy.mlEnglish · 4 months agogot himlemy.lolimagemessage-square135fedilinkarrow-up1496arrow-down141
arrow-up1455arrow-down1imagegot himlemy.lolngn@lemy.lol to Programmer Humor@lemmy.mlEnglish · 4 months agomessage-square135fedilink
minus-squareSpaceNoodle@lemmy.worldlinkfedilinkarrow-up4arrow-down1·edit-24 months ago(p += 1) resolves to the value of p after the incrementation, as does ( p = p + 1).
minus-squarefluckx@lemmy.worldlinkfedilinkarrow-up3arrow-down1·4 months agoYes. 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.
minus-squareSpaceNoodle@lemmy.worldlinkfedilinkarrow-up5·4 months agoNo. ++p returns incremented p. p += 1 returns incremented p. p = p + 1 returns incremented p. p++ returns p before it is incremented.
minus-squarefluckx@lemmy.worldlinkfedilinkarrow-up3·4 months agoRight. So i had them the other way around. :D Thanks for clarifying.
(p += 1) resolves to the value of p after the incrementation, as does ( p = p + 1).
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.
No.
++p returns incremented p.
p += 1 returns incremented p.
p = p + 1 returns incremented p.
p++ returns p before it is incremented.
Right. So i had them the other way around. :D
Thanks for clarifying.