29 Working with List: Properties

After reading this lesson, you will be able to

  • Inquire over the size of a list
  • Check if a sequence contains a specific item
  • Count the number of elements that respect a given predicate

In the previous lesson, you learned how to use the map and flatMap functions over an instance of List. These are two of its fundamental operations: when combined with pattern matching, they allow you to define the vast majority of operations you can perform for a sequence. However, implementing the same procedures over and over may not be performant and may be challenging to maintain. For these reasons, the class List provides you with many ready-to-use and performant functions for common transformations and queries. In this ...

Get Get Programming with Scala now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.