Skip to content

Instantly share code, notes, and snippets.

@tkfx
Created June 13, 2016 16:12
Show Gist options
  • Save tkfx/8ce765cb017a2d4357dbbdc8563b891a to your computer and use it in GitHub Desktop.
Save tkfx/8ce765cb017a2d4357dbbdc8563b891a to your computer and use it in GitHub Desktop.
Scala Future
import scala.util.{Success, Failure}
val f: Future[List[String]] = Future {
session.getRecentPosts
}
f onComplete {
case Success(posts) => for (post <- posts) println(post)
case Failure(t) => println("An error has occured: " + t.getMessage)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment