Skip to content

Instantly share code, notes, and snippets.

@Sammers21
Created March 2, 2018 10:02
Show Gist options
  • Save Sammers21/6dcdeea0e2aaefb0577f0a0c10861495 to your computer and use it in GitHub Desktop.
Save Sammers21/6dcdeea0e2aaefb0577f0a0c10861495 to your computer and use it in GitHub Desktop.
object hello extends App {
import scala.concurrent.ExecutionContext.Implicits.global
val f1: Future[Int] =Future.failed(new Exception("hello i m exc"))
val f2: Future[Int] = Future.successful(13)
val res = for {
f11 <- f1
f22 <- f2
} yield f11 + f22
res.onComplete{
h=>
if(h.isSuccess){
println(h.get)
}
else {
println("failed")
}
}
Thread.sleep(1000)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment