In the example below I get the exception java.util.NoSuchElementException: Future.filter predicate is not satisfied
I want to have the result Future(
Of course I figured out one solution myself. Perhaps there are better, more idiomatic, solutions?
import scala.concurrent.Future
import scala.util.{ Try, Success, Failure }
import scala.concurrent.ExecutionContext.Implicits.global
val f1 = Future( 1 )
val f2 = for {
i <- f1
if( i == 2 )
} yield "Test1"
val f3 = f2.recover{ case _ => "Test2" }
// OR val f3 = f2.fallbackTo( Future( "Test2" ) )
f3.value