Created
March 2, 2018 10:02
-
-
Save Sammers21/6dcdeea0e2aaefb0577f0a0c10861495 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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