2 ms·
Nested ?: is hard to read due to the precedence. It's better to spend a few lines and break it up: return a < b ? -1 : a > b
by kazinator 8y ago
Nested ?: is hard to read due to the precedence. It's better to spend a few lines and break it up:
return a < b
? -1
: a > b
? 1
: 0;
If that is too much:
return a < b
? -1
: a > b ? 1 : 0;
Other possibilities:
return a < b ? -1
: a > b ? 1
: 0;
return a < b ? -1
: a > b ? 1 : 0;