How to convert Map[A,Future[B]] to Future[Map[A,B]]?
问题 I've been working with the Scala Akka library and have come across a bit of a problem. As the title says, I need to convert Map[A, Future[B]] to Future[Map[A,B]] . I know that one can use Future.sequence for Iterables like Lists, but that doesn't work in this case. I was wondering: is there a clean way in Scala to make this conversion? 回答1: See if this works for you: val map = Map("a" -> future{1}, "b" -> future{2}, "c" -> future{3}) val fut = Future.sequence(map.map(entry => entry._2.map(i =