title: Multiple return statements, readability
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/36707/should-a-function-have-only-one-return-statement">Should a function have only one return statement?</a>  </p>
  </blockquote>
  
  
  
  <p>My teacher took points off on some java code I wrote (I'm still getting an A, this is just the first non 100% grade I've gotten in the java course) I'm not going to argue with the teacher on the point, but I would like to get some advice from <em>actual</em> programmers. Here is the offending piece of code:</p>
  
  <pre><code>private char byte2suit(byte val) {
      switch(val) {
          case 0: return 's';
          case 1: return 'c';
          case 2: return 'h';
          case 3: return 'd';
          }
      //fallback value
      return 'h';
      }
  </code></pre>
  
  <p>In my opinion this is much clearer that initalizing a return value, assigning in the case (and adding break; every line) then returning the value. Of course, in code other people see, my opinion isn't all powerful, so I would like to know what you guys think about multiple return statements in java (or C/C++ for that matter), if you do use multiple return statements do you use it more than the "if (this) return a; else return b;" statement? If you don't use multiple return statements, can you give a really convincing reason ( unreadable code is not a reason if the above code IS readable and is the maximum extent of my multiple return coding practice )</p>