4 ms·
I've been doing if condition1 && condition2 ... end for ages and it seems to work find, what am I missing with this new syntax?!
by tebbers 9mo ago
I've been doing
if condition1 &&
condition2
...
end
for ages and it seems to work find, what am I missing with this new syntax?!
- Sammi 9mo agoLess likely to cause git merge conflict as you don't change the original line. You only add one.
- mantas 9mo agoPersonally && in the new line seems to be much better readability. Can’t wait to use some smart cop to convert all existing multiline ifs in my codebase.
- fuzzythinker 9mo agoIn languages where placement don't matter, like c/js, I prefer leading booleans. It makes it much easier to see the logic, especially with layers of booleans.
- AlecSchueler 9mo agoI prefer the new way because if you want to remove one condition you just delete the line rather than having to edit in multiple places.
- flopsamjetsam 9mo agoI first picked up this style from the GNU C++ style guide, and it's so handy I use it in every language that accepts it.
- zelphirkalt 9mo agoIt's funny how I have been doing this way of writing the conditions in languages, where one can, like Python (if you use a pair of parentheses) and linters have yelled at me for ages to put the binary operator on the previous line. People herald these quite subjective things like truths, just because there is some tool, that they can delegate responsibility to.
- mathgeek 9mo agoFor folks who scan code bases based on the front of lines, it makes it easier to grok. Also helps with deleting and inserting lines (similar to leading or trailing commas in lists).