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

How to extract unique elements from a Scala sequence

$
0
0

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:

read more


Viewing all articles
Browse latest Browse all 25

Trending Articles