How are Scala Futures chained together with flatMap?
I'm working on using Futures for the first time in Scala and am working through an example of using the flatMap combinator; I've been following this discussion: http://docs.scala-lang.org/overviews/core/futures.html Specifically, this example: val usdQuote = future { connection.getCurrentValue(USD) } val chfQuote = future { connection.getCurrentValue(CHF) } val purchase = for { usd <- usdQuote chf <- chfQuote if isProfitable(usd, chf) } yield connection.buy(amount, chf) purchase onSuccess { case _ => println("Purchased " + amount + " CHF") } is translated to this: val purchase = usdQuote