Just watched a short video by Trey Hunner and thought it was a good rule.
Balanced Statements
If the else
statement is not more important than the if
check, then keeping it can improve readability. The if
and the else
statements are like a balance scale.
Example
Unnecessary and Confusing else
Statement
However, if the else
statement is more important than the if
check, it is better to remove the else
statement.