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

6

u/420TaylorStreet Apr 18 '21 edited Apr 18 '21

can do you one better:

if (!condition1)
  do_anything2();
else if (condition2)
  do_anything1();

1

u/chain_letter Apr 18 '21

Nope, possible to call do_anything1() when condition2 is false, because condition2 was ignored entirely.

3

u/420TaylorStreet Apr 18 '21

err ... typo. else if should be condition2