Scala Set

We saw other data structures in previous SKB like List or Map.

Let’s look at Set.

Did you notice that Set cannot contain duplicate values? A Set is a list of unique values.

When you combine the two Set, it removes the duplicated values and only keep one of each.

One thing to know is that Set do not guarantee consistant ordering. You should not rely on index of the elements. If you want to learn more, you can read this great answer on Stackoverflow.

Last thing about Set is that it has all the same function as List such as map, flatMap, filter, etc…

Reveal more information and clues
Load Exercise