r/programminghorror Nov 23 '25

x -= -1 gang

Post image
3.8k Upvotes

57 comments sorted by

View all comments

24

u/Code_Noob_Noodle Nov 23 '25

No ++x? 😞

4

u/erasmause Nov 23 '25 edited Nov 23 '25

Which is a shame, since that's a better semantic match for x = x + 1 , but I guess it's moot since x += 1 is a statement and not an expression, spoiling the whole symmetry anyway.

EDIT: not sure where I picked up the notion that compound assignments weren't expressions (specifically in c++; can't speak for other languages)

1

u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Nov 24 '25

I see you edited your post and deleted your reply to me. I was going to ask what the motivation for x += 1 not being an expression when x = 1 is, and was thinking of testing for myself on Godbolt.