I am slightly confused when to use which because futures are allowed to fail. If futures are allowed to fail, then to me, that sounds like a Try[]
in itself.
And if the Try[]
is wrapped inside a Future, then what is the difference with a regular Future[]
?
Best Answer
There's really no reason to ever use a
Future[Try[T]]
. You add no benefit over a plainFuture
, and a good deal of complexity.Trys
are sort of the synchronous version ofFutures
. You use them to wrap operations you are blocking on that might fail, or potentially-failing operations that are lazily evaluated.Futures
are for when you need asynchronous semantics as well.