News for hackers. Stuff that matters.
Re:Avoid Else, Return Early (2013) by Sean1708 on Monday March 26, 2018 @09:34AM (#16678703)
The simple cases do come up though. I've written plenty of functions which amount to little more than a single if-statement and I have had people ask me to make changes like

  foo(things) {
      stuff = do_work(things);

      if (stuff) {
          return a;
      } else {
          return b;
      }
  }
into

  foo(things) {
      stuff = do_work(things);

      if (stuff) {
          return a;
      }

      return b;
   }
in code reviews.

There are no comments on this comment yet.