A fun thing you can do with the map
method on Scala sequences (Array
, List
, Seq
, Vector
, etc.), is convert a sequence of objects into a sequence of something else, typically extracting a field from the original object to create the new sequence.
For instance, imagine that you have a case class named Person
that has two constructor parameters, firstName
and lastName
: