1

I am having a working solution, but I just wanted to ask if there is a better way of doing it. Basically, I am faced with a sequence of Future each holding one object with a Boolean as the only attribute. And I want to run a forall on the sequence. I was just wondering if there is a more elegant solution that does not require an Await. For comparison, this is my solution now:

Seq[Future[Object[Boolean]]] map 
{ Await.result(Future[Object[Boolean]], Duration.inf) } 
forall Boolean

So, is there any way I can map a Seq[Future[Object]] to a Future[Seq[Object]] without using Await?

SOLVED in comment, waiting for comment to be transformed into an answer.

jub0bs
  • 60,866
  • 25
  • 183
  • 186
SomeStranger314
  • 327
  • 1
  • 3
  • 12
  • See https://stackoverflow.com/questions/26717249/how-to-flatten-a-list-of-futures-in-scala - while not an exact duplicate, it answers the last question in the post, and I believe you can go on from there. – Tzach Zohar May 24 '18 at 15:56
  • Oh perfect. I should have put more time into research. Will you transform your comment to an answer so I can choose it as best answer? – SomeStranger314 May 24 '18 at 15:57

0 Answers0