vendredi 5 mars 2021

Simplifying return of If Statements

I'm having writers block on this if statement and simplifying it. Is there a more efficient way to implement this if the nests are returning the same value? I may just be missing it.

            if (string == "something")
            {
                if (object1 == null || object2 == null || object3 == null)
                {
                    return state1;
                }
            }

            if (attribute1 || attribute2 || attribute3)
            {
                return state1;
            }

            return state 2; 

Aucun commentaire:

Enregistrer un commentaire