Using Guard Clauses to Clean Up Your Conditionals [A How-To Guide]by@wagslane
1,708 reads
1,708 reads

Using Guard Clauses to Clean Up Your Conditionals [A How-To Guide]

by Lane Wagner2mMarch 15th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Guard Clauses are a way to leverage the ability to return early from a function (or break/continue through a loop) to make nested conditionals more one-dimensional. Complex and nested if/else statements become a cognitive burden to reason about. The way errors are handled in go naturally encourage the developer to make use of guard clauses. Guard clauses can be much easier to read and understand in go than in other languages. The author is the Founder at qVault, and founder of http://qvault.io.
featured image - Using Guard Clauses to Clean Up Your Conditionals [A How-To Guide]
Lane Wagner HackerNoon profile picture
Lane Wagner

Lane Wagner

@wagslane

Founder of Boot.dev. Whining about coding sins since 2011. Committing coding sins for the same.

About @wagslane
LEARN MORE ABOUT @WAGSLANE'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Lane Wagner HackerNoon profile picture
Lane Wagner@wagslane
Founder of Boot.dev. Whining about coding sins since 2011. Committing coding sins for the same.

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Also published here