Re:Read this post ‘unless’ you’re not a Ruby developer
by weatherlight on Tuesday December 13, 2022 @10:11AM
(#33969853)
When I write ruby, and I love ruby, I don't do too much condition branching of logic.
This article screams, "I don't use a linter" or "I work at a company that doesn't have a style guide."
[ Parent
| on HN ]
Re:Read this post ‘unless’ you’re not a Ruby developer
by thomascgalvin on Tuesday December 13, 2022 @10:19AM
(#33969978)
I don't write ruby at all, but this is how I write my Java, Kotlin, and Javascript; fail-fast at the top of the method, with the happy path following.
And I'll take it one step further: I see a multi-line branch as a code smell in and of itself. If something in a branch takes multiple statements, I am of the opinion that the body of that branch should probably broken out into a method.
So if we're going off the article title, my code might look something like
val isNotRubyDev = !user.isRubyDev
if(isNotRubyDev) return
// ...read article