February 2018
Intermediate to advanced
552 pages
13h 46m
English
We can get the following benefits from the Scala flatMap() function:
The flatMap() function is defined, as shown here in all Scala Container classes:
final def flatMap[B](f: (A) ⇒ C[B]): C[B]
Here, C is a Scala container class like List, Option, Try, Future, and so on.
The flatMap() function takes a function f as an argument. The function f is defined as f: A => C[B], meaning it takes element A as input, processes it, and outputs it as C[B].
Here, A and B are of the same type or may be different types. The following diagram shows how the Scala flatMap() function works internally:
Let us explore the ...