It's really nice in validation functions, where certain conditions must be met before proceeding. By returning early (maybe with a log about why), you keep the validation logic entirely flat. The alternative is making a deeply nested set of checks that are even more difficult to understand, since deep nesting makes it more difficult to know which lines of code are related
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It's really nice in validation functions, where certain conditions must be met before proceeding. By returning early (maybe with a log about why), you keep the validation logic entirely flat. The alternative is making a deeply nested set of checks that are even more difficult to understand, since deep nesting makes it more difficult to know which lines of code are related