title: overloaded method value async with alternatives:
body: <p>When I have the following code everything compiles fine.</p>
  
  <pre><code> def create(name: String, age: Int) = Action.async {
      val json = Json.obj(
        "name" -&gt; name,
        "age" -&gt; age,
        "created" -&gt; new java.util.Date().getTime())
  
      collection.insert(json).map(lastError =&gt;
        Ok("Mongo LastError: %s".format(lastError)))
    }
  </code></pre>
  
  <p>But when extract the content to another method as follows</p>
  
  <pre><code> def create(name: String, age: Int) = Action.async {
     createPerson(name,age)
   }
  
    def createPerson(name: String, age: Int) = Action.async {
      val json = Json.obj(
        "name" -&gt; name,
        "age" -&gt; age,
        "created" -&gt; new java.util.Date().getTime())
  
      collection.insert(json).map(lastError =&gt;
        Ok("Mongo LastError: %s".format(lastError)))
    }
  </code></pre>
  
  <p>it gives the error</p>
  
  <pre><code>[error] /media/pubudu/NTFSPartition/projects/catnet/data-collector-backend/app/controllers/Application.scala:50: overloaded method value async with alternatives:
  [error]   [A](bodyParser: play.api.mvc.BodyParser[A])(block: play.api.mvc.Request[A] =&gt; scala.concurrent.Future[play.api.mvc.Result])play.api.mvc.Action[A] &lt;and&gt;
  [error]   (block: play.api.mvc.Request[play.api.mvc.AnyContent] =&gt; scala.concurrent.Future[play.api.mvc.Result])play.api.mvc.Action[play.api.mvc.AnyContent] &lt;and&gt;
  [error]   (block: =&gt; scala.concurrent.Future[play.api.mvc.Result])play.api.mvc.Action[play.api.mvc.AnyContent]
  [error]  cannot be applied to (play.api.mvc.Action[play.api.mvc.AnyContent])
  [error]   def create(name: String, age: Int) = Action.async {
  </code></pre>
  
  <p>Isn't the two code sections doing the same thing? If not, how can I extract the content of the method without getting the error? What I want to do is to call the extracted method from two different places.</p>