3 ms·
I was more or less required to use guard clauses by my manager at my previous job. I used to hate being forced to use them, just because as a recent computer s
by toomanybeersies 9y ago
I was more or less required to use guard clauses by my manager at my previous job.
I used to hate being forced to use them, just because as a recent computer science graduate I was happy with nested conditionals everywhere. But guard clauses make life so much easier, I eventually discovered.
They make testing your code a lot easier, and also make reasoning about the code and reading it so much easier.
Ruby makes writing methods with guard clauses a breeze, since you can just write something like `return if x > 7`.