Skip to content

Instantly share code, notes, and snippets.

@mishin
Forked from tkfx/ScalaFuture.scala
Created July 18, 2016 21:45
Show Gist options
  • Save mishin/f51e9f16312685274346fa6d1f3bc799 to your computer and use it in GitHub Desktop.
Save mishin/f51e9f16312685274346fa6d1f3bc799 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