Quantcast
Channel: alvinalexander.com - sequence
Viewing all articles
Browse latest Browse all 25

Scala tip: How to extract a field from a sequence of objects to create a new sequence

$
0
0

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:

read more


Viewing all articles
Browse latest Browse all 25

Trending Articles