3 ms·
True, which only makes my poorly-targeted point on bad parsability. Reading the code requires backtracking around a conditonal control statement, and in a form
by web007 10y ago
True, which only makes my poorly-targeted point on bad parsability.
Reading the code requires backtracking around a conditonal control statement, and in a format more verbose than ternary. Most places I've worked have bans or limits on ternary to single boolean cases for the same reason: It's hard for people to understand the control flow of operations around conditional assignment. A new language that lets you perpetuate painful code isn't helping as much as it could.
It's much simpler for people to parse the more verbose case with an IF and two return blocks, and the compiler shouldn't care since it can generate the same code either way.
- gliptic 10y agoI think that is quite subjective. I prefer this version with one return. I don't want more returns than necessary, and I want them as far up in the nesting as possible so they are easy to see. Returns are, after all, control-flow altering.