ngn@lemy.lol to Programmer Humor@lemmy.mlEnglish · 2 years agogot himlemy.lolimagemessage-square129linkfedilinkarrow-up1222arrow-down122
arrow-up1200arrow-down1imagegot himlemy.lolngn@lemy.lol to Programmer Humor@lemmy.mlEnglish · 2 years agomessage-square129linkfedilink
minus-squarenelson@lemmy.worldlinkfedilinkarrow-up0·2 years 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-up0·2 years agoNo. ++p returns incremented p. p += 1 returns incremented p. p = p + 1 returns incremented p. p++ returns p before it is incremented.
minus-squarenelson@lemmy.worldlinkfedilinkarrow-up0·2 years agoRight. So i had them the other way around. :D Thanks for clarifying.
Yes.
p++==p+= 1==p = p + 1are all the same if you use it in an assignment.++pis 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.