Scala: Use fold to serialize any number of Futures
Scala’s for-comprehensions are extremely useful and offer much more than just looping. For this post, I would like to focus on using for-comprehensions for manipulating Futures. More specifically, for serializing Futures.
Let’s assume that we have a function that performs some kind of logic and returns a Future:
def addOneAndPrint(num: Int): Future[Unit] = { Future { val addedOne = num + 1 print(addedOne + " ") } } Users of such a fuction, may want to call it more than one time and additionally, to call it serially.
[Read More]