Other Collections
Now that we've covered the List and some relevant
Traversables in the Scala standard library, we should also visit some other useful collections Scala provides. Even though this section has less theoretical material, this means that we'll have more time on the final activities of the chapter.
Sets
Sets are
Iterables that
contain no duplicate elements. The
Set class
provides methods to check for the inclusion of an element in the collection, as well as combining different collections. Note that since
Set inherits from
Traversable, you can apply all the higher-order functions we've seen previously on it. Due to the nature of its
apply method, a
Set can be seen as a function of type
A =>
Boolean, which returns
true if the element ...
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