With Futures
there is an easy way to transform Seq[Future]
to a Future[Seq]
:
Future.sequence(seqOfFutures)
I could not find an analog thing with Try
.
It works with foldLeft
but what I really like would have something like Try.sequence(seqOfTry)
.
Is there a reason that such a function is not provided?
How is this done properly?
Semantics:
A List of the values on Success: Success(Seq(1,2,3,4))
For Failure there are 2 possibilities:
Fails on the fist
Failure
and returns it. This is handled by this question: listtryt-to-trylistt-in-scalaGathers all
Failures
and returns a 'compound' Failure.
Is there also a solution for the 'compound' Failure?