lundi 6 juin 2016

What is the most efficient way to write the following condition

I have some code that looks like this:

if (a == 0 or b == 0) {
    if (c == true) {
        return 0
    else if (a == 0)
        a = 1
        c = true
    else if (b == 0)
        b = 1
        c = true
    }
}

What would be the most efficient way to write this code without having to check again for which of a or b is equal to 0? This might have been already answered but I have no idea how would people ask this question.

Aucun commentaire:

Enregistrer un commentaire