Code inspection: Invert 'if' statement to reduce nesting
Last modified: 11 February 2024tip
Consider the following code snippet:
As you can see, the if
blocks encompass the whole body of the method. This presents an opportunity to make code more readable by getting rid of the nested scope as follows: