Search code examples
scalafuturesequences

Convert Future[Seq[(String, String)]] to Future[Seq[(String)]]


I am trying to convert Future[Seq[(String, String)]] to Future[Seq[(String)]] using the following:

sortedSeq.map(_._2)

so sortedSeq is of type Future[Seq[(String, String)]]

but I keep getting the error :

 value _2 is not a member of Seq[(String, String)]

What am I doing wrong ?


Solution

  • sortedSeq.map will apply the mapping to the Future, but you want it to apply to the elements of the Seq inside the future.

    So something like:

    sortedSeq.map(_.map(_._2))
    

    so you map on the contents of the Seq in the future.

    If you have a code sample that produces this to try it out it may be easier.