this post was submitted on 04 Jun 2025
1016 points (98.8% liked)

Programmer Humor

23844 readers
3221 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
[โ€“] [email protected] 202 points 2 days ago* (last edited 2 days ago) (34 children)

This is too stupid so I had to check.

Fuck me.

[โ€“] [email protected] 113 points 2 days ago* (last edited 2 days ago) (12 children)

Hm, playing devil's advocate, I think it is because the minus has not been defined as a string operation (e.g. it could pop the last char), so it defaults to the mathematical operation and converts both inputs into ints.

The first is assumed to be a concat because one of the parcels is a string...

It's just doing a lot of stuff for you that it shouldn't be in first place ๐Ÿคญ

[โ€“] [email protected] 12 points 2 days ago (1 children)

Yeah, this looks dumb on the surface, but you've got bigger problems if you're trying to do math with strings

[โ€“] Klear 4 points 1 day ago

Better than doing physics with strings

load more comments (10 replies)
load more comments (31 replies)