title: What is the difference between using the return statement and defaulting to return the last value?
body: <p>I am learning Scala and I noticed something about using the return statement.</p>
  
  <p>So, obviously in Scala, if you don't have a return statement, the last value is returned by default. Which is great. But if you use the return statement without specifying the return type, Scala says <code>"error: method testMethod has return statement; needs result type"</code></p>
  
  <p>So this works</p>
  
  <pre><code>  def testMethod(arg: Int) = {
      arg*2
    }
  </code></pre>
  
  <p>but this gives the error</p>
  
  <pre><code>  def testMethod(arg: Int) = {
      return arg*2
    }
  </code></pre>
  
  <p>This makes me scratch my chin and go</p>
  
  <blockquote>
    <p>Mmmmmmmm... There must be a reason for that.</p>
  </blockquote>
  
  <p>Why is the explicit type declaration needed when you use a return statement but not when you let Scala return the last value? I assumed they were exactly the same thing, and that return statements are just for if you want to return a value inside a nested function/conditional, etc. (In other words, that a "return" statement is automatically inserted to your last value by the compiler.. if not present anywhere else in the method)</p>
  
  <p>But clearly I was wrong. Surely there must be some other difference in the implementation?</p>
  
  <p>Am I missing something?</p>