Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import scala.concurrent._
- import ExecutionContext.Implicits.global
- import scala.util.{Success, Failure}
- object Demo {
- def main(args: Array[String]){
- val b2: Future[List[Int]] = Future {
- List(1,2)
- }
- val c2:Future[List[Int]] = b2.map( x => x.map( _*3 ) )
- // Note how in this case the two `map` do not have the same meaning.
- c2 onComplete {
- case Success(value) => println(s"Value: $value")
- case Failure(t) => println("An error has occured: " + t.getMessage)
- }
- // Outputs: Value: List(3, 6)
- Thread.sleep(2000)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement