title: Why does Scala require a return type for recursive functions?
body: <p>In the code snippet included below, I have a recursive function call, used to facilitate a retry if a network call fails (Amazon SimpleDB will occasionally return a 503 and require retry.) </p>
  
  <p>When I try to compile, the Scala complains <code>recursive method simpledb_update needs result type</code>. </p>
  
  <pre><code>// sends data to SimpleDB. Retries if necessary
  def simpledb_update(name: String, metadata: Map[String,String], attempt: Int) = {
   try {
    db(config("simpledb_db")) += (name, metadata)
   } catch {
    case e =&gt;
     // if it fails, try again up to 5 times
    if(attempt &lt; 6)
    {
     Thread.sleep(500)
     simpledb_update(name, metadata, attempt + 1)
     } else
       AUlog(name + ": SimpleDB Failed")
     }
   }
  </code></pre>
  
  <p>Why is  this required on recursive functions? My thought is to just return a true/false boolean to satisfy the compiler... the following compiles fine. </p>
  
  <pre><code>// sends data to SimpleDB. Retries if necessary
   def simpledb_update(name: String, metadata: Map[String,String], attempt: Int): Boolean = {
   try {
    db(config("simpledb_db")) += (name, metadata)
    true
   } catch {
    case e =&gt;
     // if it fails, try again up to 5 times
     if(attempt &lt; 6)
     {
      Thread.sleep(500)
      simpledb_update(name, metadata, attempt + 1)
     } else
      AUlog(name + ": SimpleDB Failed")
      false
    }
  }
  </code></pre>