在kotlin中有没有Future.sequence类似物?

在scala中,您可以将期货收藏“映射”到收藏的未来:

val l: List[Future[String]] = List(Future {"1"}, Future {"2"}) val x: Future[List[String]] = Future.sequence(l) 

如何相同的事情,但与科特林?

假设你使用协程:

 val l: List<Deferred<String>> = (1..2).map {i -> async(Unconfined){ "$i" }} val x: Deffered<List<String>> = async(Unconfined) { l.map {it.await()} }