1

I have method but i can't understand why i have the type mismatch error . It my by close to this issue Type Mismatch For Comprehension but i cant figure out why ??

i just want to create new list of (List[jsvalue], jsvalue) .

this is the error

Error:(41, 11) type mismatch;
 found   : List[(List[play.api.libs.json.JsValue], play.api.libs.json.JsValue)]
required: scala.concurrent.Future[?]
    a <- x.map(_._1)
      ^

thanks miki

def test(future: Future[List[(List[JsValue], JsValue)]]) = {
  future.flatMap(x => {
    for {
      a <- x.map(_._1)
      b <- x.map(_._2)
    } yield (a, b)
  })
Community
  • 1
  • 1
MIkCode
  • 2,185
  • 4
  • 23
  • 41
  • 2
    try `future.map`. With `flatMap` the `x => ...` function must return `Future`. – phadej Dec 26 '14 at 11:03
  • 1
    Yes, you (probably) want `map`, not `flatMap`. Also, note, that (provided, you make that change), the return value of your function is going to be `Future[(List[List[JSValue]], List[JSValue])]`, which, I suspect, might not be what you are actually looking for. – Dima Dec 26 '14 at 14:11
  • i want to get rid of the future .... – MIkCode Dec 26 '14 at 20:12
  • 2
    @MIkCode you can only do that using a blocking operation; see `Await.result`. – rightfold Dec 26 '14 at 20:22

0 Answers0