Scala Set

We saw other data structures in previous SKB likeListorMap.

Let's look atSet.

Did you notice thatSetcannot contain duplicate values? ASetis a list of unique values.

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

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

Last thing aboutSetis that it has all the same function asListsuch asmap,flatMap,filter, etc…

Reveal more information and clues
Load Exercise