mercredi 20 avril 2016

Returning inside an else statement

Should you write your functions like this:

int foo()
{
    if (bar)
        return 1;
    return 2;
}

Or like this?

int foo()
{
    if (bar)
        return 1;
    else
        return 2;
}

Is one way objectively better than the other, or is it a matter of personal preference? If one way is better, why?

Aucun commentaire:

Enregistrer un commentaire