February 2018
Intermediate to advanced
552 pages
13h 46m
English
It is now a good time to understand how the map() function works in Scala. It's the same for all Scala containers such as Collections, Monads, and more. It is defined as shown in the following example in all Scala container classes:
final def map[B](f: (A) ⇒ B): C[B]
Here, C is a Scala container class such as List, Option, Try, Future, and so on.
The map() function takes a function f as an argument. The function f is defined as f: A => B that means it takes the element A as input, processes it and outputs element B.
Here, A and B are of the same type or may be different types.
When we apply this map() function on Container C, the map() function performs the following steps: