title: Scala - Unit found required: play.api.mvc.SimpleResult
body: <p>I'm really confused here, i'm probably missing something obvious so it would be great if someone could point me into the right direction.  </p>
  
  <p>I've got this following function that returns a future of a SimpleResult type but it has a unit instead .  I'm not sure why it is saying this as i am mapping the futureList result</p>
  
  <pre><code>  def find(key: String, value: String) = Future[SimpleResult] {
  
    val cursor: Cursor[JsObject] = coll.
      find(Json.obj(key -&gt; value)).
      cursor[JsObject]
  
    val futureList: Future[List[JsObject]] = cursor.collect[List]()
  
    val futureResult: Future[SimpleResult] = futureList.map { item =&gt;
  
      if(item.isEmpty) {
  
          Ok(JsArray()).as(JSON)
      }
      else 
           Ok(Json.toJson(item))     
   }
  } 
  </code></pre>
  
  <p>Edit</p>
  
  <p>I've changed it to the following from the advice given by Marth</p>
  
  <pre><code>  def find(key: String, value: String) = Future[SimpleResult] {
  
    val cursor: Cursor[JsObject] = coll.
      find(Json.obj(key -&gt; value)).
      cursor[JsObject]
  
    val futureList: Future[List[JsObject]] = cursor.collect[List]()
  
     futureList.map { item =&gt;  Ok(Json.toJson(item))    }
  
  }
  </code></pre>
  
  <p>Eclipse is warning about the following </p>
  
  <p>type mismatch; found : scala.concurrent.Future[play.api.mvc.SimpleResult] required: 
   play.api.mvc.SimpleResult</p>
  
  <p>Although the function is meant to return a scala.concurrent.Future[play.api.mvc.SimpleResult]</p>