this post was submitted on 13 Dec 2025
632 points (97.6% liked)
Programmer Humor
27898 readers
2536 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
But of course -- It's just flipping around the
-=operator!Nope, it is not.
while
x=-iis the unary minus operator which negates the value right of it. It doesn't matter if that value is a literal (-3), a variable (-i) or a function (-f()).x-=iis short forx = x-i, and here it's a binary subtraction, so x is set to the result of i subtracted from x.I need to append
/sto my future silly replies I think... that said, I'll never pooh-pooh a well thought response, so thanks for the nice write-up!Thanks, I totally missed your sarcasm :)
There's a couple people in this threat who seem to actually think that
x = -iis some weird magic instead of a standard feature that's present in every major programming language.That only works if x is already 0
If i is 10 and x is zero, yes, x -= i would have a value of -10. If x was 5 from something else previously, x-=i would end with an x value of -5.