My favorite programming trick.
With the early
returnpattern, you check for the opposite of the thing you want, and
returnearly to end the function when that’s the case.
This reduces nested
ifstatements, and makes your code a bit easier to read.