dimanche 6 décembre 2015

Can the following IF-ELSE block be compressed into a single IF statement?

I have the following if-else block:

boolean condA = false, condB = true;

if (!condA) {
    // do WORK_C
} else {
    if (condB) {
        // do WORK_C
    }
}

While writing this up, I realized that I am doing the same work in both condition matches. I wonder if this can be compressed any further.

I'm willing to provide more info/context, should it be required.

Aucun commentaire:

Enregistrer un commentaire