Reputation: 20405
For a given Seq
wrapped in a Future
, namely for instance
import scala.concurrent._
import ExecutionContext.Implicits.global
val xs = Future { Seq(1,2,3) }
how to extract the first (one only) value in the collection into another Future
, namely
Future { 1 }
Upvotes: 0
Views: 284
Reputation: 8663
val xs = Future { Seq(1,2,3) }
val x = xs.map(_.head)
x
will be another Future
, and xs
is still usable, so you can do anything with it.
Upvotes: 6