News for hackers. Stuff that matters.
Re:Clear is better than clever [pdf] by Retric on Tuesday May 07, 2019 @07:40AM (#19848476)
That’s a nested if statement which stops being clear.

  return a > b ? 1 : a < b ? -1 : 0;  
  return a < b ? -1 : a == b ? 0 : 1;
  return a == b ? 0 : a < b ? 1 : -1;
  return a > b ? 1 : a == b ? 0 : -1;
  return a != b ? a > b ? -1 : 1 : 0;  
  return a != b ? a < b ? 1 : -1 : 0;  
  
Are all equally valid ways of writing that code. You can get used to a convention that makes it seem more clear, but reading it they are all equally easy to decode.

There are no comments on this comment yet.