jeudi 27 décembre 2018

break out from nested if

I am modifying quite a large system and I want to avoid risky changes in many places.

i want to (in one case) break a nested if and proceed previous else statement. if it is possible.

if (otherBool)
{
    if(ID != 2)
    {
        html += "";
    }
    else
    {
        // break
    }
}

else if (ID == 2)
{
    html += "";
}
else
{
    html += "";
}

in this case, if otherBool is true and ID equal 2 i want in nested else make break that condition and go to previous (just like the otherBool would be false from start).

i wonder about break, because that if is inside switch.

it cannot be if(otherBool && id!=2) becaause in the nested if will be more statements.

Aucun commentaire:

Enregistrer un commentaire