DEV Community

Discussion on: How I improved my code by returning early, returning often!

Collapse
 
shogg profile image
shogg • Edited

The thing with pure functional programming is .. you can't have variables (persisted inner state). You can only chain function calls. You're not allowed to check a result twice.

Checking early doesn't make it more functional. But you are right, checking/returning early helps to prevent side effects and makes the code more clear.