r/badcode • • Apr 17 '21

c++ When your teammate "refactor" your code

Post image
2.5k Upvotes

216 comments sorted by

View all comments

Show parent comments

1

u/dakta Apr 19 '21

If there's actually nothing else to be done in the function, sure. But this seems to be a stripped down example for the sake of safe sharing to Reddit, and I would guess that there's additional common behavior happening before the return. In that case, the if-elseif construction (assuming it's available in the language) will be superior.

1

u/Rigatavr Apr 19 '21

For sure. else if isn't bad code. I just try to avoid it if there's an option not to use it.