By Alvin Alexander. Last updated: June 4, 2016
Thinking in Scala: The map
method on the Scala collections classes is used to transform an input collection to an output collection using a transformation algorithm you supply. This is similar to the way an electricity transformer converts voltage from one purpose to another. The following examples come from the Scala Cookbook: