This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 10.21, “How to Extract Unique Elements from a Scala Sequence”
Problem
You have a collection that contains duplicate elements, and you want to remove the duplicates.
Solution
Call the distinct
method on the collection: