Once more... Invert if statement to reduce nesting

ok...I know this is probably a well beaten dead horse, but..

public function(stringorobject param)
    if(somethingthatisrequiredforfunctionality == null)
         somethingthatisrequiredforfunctionality = new somethingthatisrequiredforfunctionality () { member1="initialvalue", member2="anotherinitialvalue" };

    // go ahead an use somethingthatisrequiredforfunctionality
   return callotherfunction(somethingthatisrequiredforfunctionality);

Why is resharper saying anything about reducing nesting - how the heck else do you write this? lol



1 comment
Comment actions Permalink

Hi Robert,

Couldy ou please provide a full code sample/solution, which will demonstrate this behavior? I cannot get this suggestion to invert if statement on this piece of code, unfortunately.

Thank you in advance!


Please sign in to leave a comment.