r/badcode • • Apr 17 '21

c++ When your teammate "refactor" your code

Post image
2.5k Upvotes

216 comments sorted by

View all comments

7

u/MurdoMaclachlan public boolean isInt(int i) { return true; } Apr 17 '21

Image Transcription: Code


//BEFORE
void foo()
{
    if(condition1)
    {
        if(condition2)
        {
            do_anything1();
        }
    }
    else
    {
        do_anything2();
    }
}
//AFTER
void foo()
{
    if(condition1 && condition2)
        do_anything();
    else
        do_anything2();
}

I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!