4 ms·
Firstly, you can't compare if statements to ternary expressions. To compare apples to apples, you need to compare: 1) if statements with single assignment state
by solipsism 6y ago
Firstly, you can't compare if statements to ternary expressions. To compare apples to apples, you need to compare: 1) if statements with single assignment statements in both branches, assigning to the same variable, and 2) assignments with ternary expressions on the right side.
In that apples-to-apples comparison, it's really a toss up which is more readable. Looking at the if statement, anyone who has been reading code for any amount of time is going to immediately recognize the pattern. There's no "scanning two sides".