Skip to content

Instantly share code, notes, and snippets.

@chrisphelps
Last active August 29, 2015 14:02
Show Gist options
  • Save chrisphelps/419201cc30b3de9e56aa to your computer and use it in GitHub Desktop.
Save chrisphelps/419201cc30b3de9e56aa to your computer and use it in GitHub Desktop.
For comprehension over futures
val f1 = future { 5 }
val f2 = future { "str" }
val f3 = (s: String) => future { s + "vap" }
val f4 = for {
a <- f1
b <- f2
c <- f3(b)
} yield c * a
f4 onSuccess {
case txt => println(txt)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment