News for hackers. Stuff that matters.
Re:What’s New in C# 7.0 by douche on Thursday August 25, 2016 @06:26AM (#12357971)
Most of the time when I use switches, I'm returning from inside the case, because I tend to pull the switch out into another function.

It's usually a good idea to create a new scope with your cases, so you can avoid some irritating variable name clashes, since, unlike and if, switch cases don't automatically do that, i.e.

  switch(foo) {
    case 0:
      var bar = 2;
      // do stuff...
      break;
    case 1:
      var bar = 47; // error, conflicting variable name
      // do stuff...
      break;
  }

There are no comments on this comment yet.