News for hackers. Stuff that matters.
Re:Clear is better than clever [pdf] by kazinator on Monday May 06, 2019 @01:32PM (#19841742)
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;

There are no comments on this comment yet.