title: foreach in method to return value
body: <pre><code>def a: Int = {
    for(i &lt;- Array(1,2,3,4,5)){
      if(i == 3)
        return i
    }
  }
  </code></pre>
  
  <p>The above method will not compile, I get the following error:</p>
  
  <pre><code>error: type mismatch;
   found   : Unit
   required: Int
         for(i &lt;- Array(1,2,3,4,5)){
               ^
  </code></pre>
  
  <p>The expected behaviour is that the method returns 3. What is wrong with my code?</p>