in normal Scala map and flatMap are different in that flatMap will return a iterable of the data flattened out into a list. However in the Akka documentation, map and flatMap seem to do something different?
http://akka.io/docs/akka/1.1/scala/futures.html
It says "Normally this works quite well as it means there is very little overhead to running a quick function. If there is a possibility of the function taking a non-trivial amount of time to process it might be better to have this done concurrently, and for that we use flatMap:"
val f1 = Future {
"Hello" + "World"
}
val f2 = f1 flatMap {x =>
Future(x.length)
}
val result = f2.get()
Can someone please explain what is the difference between map and flatMap here in Akka futures?