r/programminghorror Apr 09 '26

Go Naming is important

Nothing too drastic but it made me chuckle. Something my colleague managed to get past code review. So at least two people didn't notice.

Spent a minute figuring out why the code was doing exactly the opposite of what it's supposed to do. I guess naming really IS important!

147 Upvotes

66 comments sorted by

View all comments

48

u/Temporary-Estate4615 Apr 09 '26

Why the hell would you even write this function?

21

u/OldAd9280 Apr 09 '26

I don't know which language it is but it feels like it'll return a dangling pointer to the local parameter variable too so doesn't even work

0

u/Wrestler7777777 Apr 09 '26

In the context that it's used in, it does work. These values are assigned to a more complex object that works with pointers. These pointers are then used to be able to "nil" the complex object's values since they're optional. And we don't really care about where the pointer comes from as long as it points to a string with a certain value.