Reputation: 1578
After seeing this statement on Scala
future fallback
method I was trying to permutate the success
and failure
variable values. I'm not able to follow with this case
Future fallbackTo combines 2 Futures into a new Future, and will hold the successful value of the second Future if the first Future fails.
I have a simple code like :
val success = Future{new Exception("Failure from success")}
val failure = Future{'c'}
val fallBackOperation = success.fallbackTo(failure)
val result= Await.result(fallBackOperation, Duration.Inf)
println(result)
Future(Success(java.lang.Exception: Failure from success))
As per the documentation
I was excepting failure
variable as outcome how ever I'm getting the outcome from success
variable. Is there anything I'm missing?
Upvotes: 1
Views: 372