I like the idea of having only one return
statement per method.
What do you do in this situation though?
public static string ChopText(string Text)
{
if (String.IsNullOrEmpty(Text))
{
// return here ?????
}
}
The only alternative I can think of is setting a flag, and then checking for the flag.
Problem is, I don't like having huge if statements that span more than a page. I've also seen ugly nested if statements as a result of this.
It is OK to replace nested conditional with guard clauses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With