News for hackers. Stuff that matters.
Re:GitHub Copilot’s Code Brushes by 9dev on Sunday January 15, 2023 @03:12AM (#34387708)
This would be a perfect case for a match expression, which, surprisingly, PHP now supports:

  return match(true) {
    $a == null && $b == null => null,
    $a < $b => -1,
    $a > $b => 1,
    $a == $b => 0,
    default => null;
  }
I’m surprised this feature isn’t prevalent in modern languages. It makes the code so concise and easy to understand, it’s marvellous.

There are no comments on this comment yet.