switch statement with returns -- code correctness
        Posted  
        
            by houbysoft
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by houbysoft
        
        
        
        Published on 2010-06-17T20:36:12Z
        Indexed on 
            2010/06/17
            20:43 UTC
        
        
        Read the original article
        Hit count: 253
        
Hi, let's say I have code in C with approximately this structure:
switch (something)
{
case 0:
  return "blah";
  break;
case 1:
case 4:
  return "foo";
  break;
case 2:
case 3:
  return "bar";
  break;
default:
  return "foobar";
  break;
}
Now obviously, the "break"s are not necessary for the code to run correctly, but it sort of looks like bad practice if I don't put them there to me.
What do you think? Is it fine to remove them? Or would you keep them for increased "correctness"?
© Stack Overflow or respective owner