3 ms·
Well, he's right that it's opinionated. If I were to contribute to that project I'd opinionatedly implement the exact opposite linter, suggesting proper if bloc
by tpoacher 5y ago
Well, he's right that it's opinionated. If I were to contribute to that project I'd opinionatedly implement the exact opposite linter, suggesting proper if blocks instead of a ternary expression.
The reason is simple: visual code structure.
A bespoke if block provides you with appropriate visual semantics that that part of the code involves a decision point.
By contrast, the ternary operator is useful when you want to visually obfuscate that fact, and make the code terser and more focused on the fact that an assignment is taking place, whose value is determined by an expression (which upon closer inspection happens to be conditional).
Yes I know that in the age of super-fat IDEs everything is but a search away, but, I've just come off from reading that other article from today about the guy who handwrites all his code.
So clearly low-level visual structure and ease of mental debugging still matters, no matter how bloated and feature-full your IDE is.
But what do I know. I still code on vim/nano.
- wirthjason 5y agoThis! When reading/skimming through source code I find the structure very important to understand that a decision is being made and not just a simple variable assignment. Sometimes more code is easier to read than shorter code. Even