News for hackers. Stuff that matters.
Re:My Favourite Diff by Cyberdog on Monday April 06, 2020 @03:19AM (#22791519)
It reduces code duplication at the cost of increasing complexity and error-prone-ness, and there are ways to reduce the duplication. For example, given the following snippets:

    switch ($foo) {
      case 123: 
        // do 1
      case 23:
        // do 2
      default:
        // do 3
    }
    
    if ($foo == 123) {
      do1();
      do2();
      do3();
    }
    else if ($foo == 23) {
      do2();
      do3();
    }
    else {
      do3();
    }
Yes, the second one is more verbose and duplicates code, but I think it's also far more clear in terms of intention.
Re:My Favourite Diff by dalemyers on Monday April 06, 2020 @07:01AM (#22792588)
You can even take it a step further:

    if ($foo == 123) {
      do1();
    }
    
    if ($foo == 123 || $foo == 23) {
      do2();
    }
    
    do3();