Skip to content

Instantly share code, notes, and snippets.

@bthuillier
Created December 10, 2015 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bthuillier/df8107dee5bb90b1cdbb to your computer and use it in GitHub Desktop.
Save bthuillier/df8107dee5bb90b1cdbb to your computer and use it in GitHub Desktop.
@ import scala.concurrent.{ Future, ExecutionContext }
import scala.concurrent.{ Future, ExecutionContext }
@ import scala.concurrent.ExecutionContext.Implicits._
import scala.concurrent.ExecutionContext.Implicits._
@ {
def testF[A](x: => Future[A]): Future[A] = {
println("here")
val future = x
future
}
}
defined function testF
@ testF(Future { println("in future") })
here
in future
res19: Future[Unit] = scala.concurrent.impl.Promise$DefaultPromise@4e6a286d
@ testF(Future.successful(println("in future")))
here
in future
res21: Future[Unit] = scala.concurrent.impl.Promise$KeptPromise@2870bb4a
@ testF(Future.failed {println("failed"); new Exception})
here
failed
res23: Future[Nothing] = scala.concurrent.impl.Promise$KeptPromise@442bca3b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment