Transforming Data
The first category we will discuss is transformation functions. A transform function modifies each element of a collection by walking through its contents and modifying each item with a transformer function provided as an argument. The transform function then returns the modified collection.
Two commonly used transform functions are map and flatMap.
map
The map transform function iterates through the collection it is called on and applies its transformer function to each element. The result is a collection of the transformed elements. (Keep in mind that we are talking about the map function, not to be confused with the mapOf function or the Map type.)
Both the map and flatMap functions are commonly used ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access