this post was submitted on 13 Dec 2025
630 points (97.6% liked)

Programmer Humor

27898 readers
2110 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

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] spongebue@lemmy.world 2 points 4 days ago (16 children)

x = -i;

Do many languages let you do that? When it's in front of a variable I would've expected it to be a subtraction operator only and you would need to do x = -1 * i;

[–] quilan@lemmy.world 1 points 3 days ago (4 children)

But of course -- It's just flipping around the -= operator!

[–] spongebue@lemmy.world 1 points 3 days ago* (last edited 3 days ago)

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.

load more comments (3 replies)
load more comments (14 replies)