mardi 2 juin 2020

If else if shortening

I can see there are so many related questions to this. Could not find anything specific addressing my query. Here is my question:

How can i shorten the below if else condition:

If (condition1)
{
    If(condition2)
    {
        Logic A
    }
}
Else if (condition3)
{
    Logic A
}

One way i could come up was as below:

If (condition1 && condition2  ||  !condition1 && condition3)
{
    Logic A
}

Just wondering if there is a better way of doing it?

Aucun commentaire:

Enregistrer un commentaire