We saw other data structures in previous SKB likeList
orMap
.
Let's look atSet
.
Did you notice thatSet
cannot contain duplicate values? ASet
is 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 thatSet
do 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 aboutSet
is that it has all the same function asList
such asmap
,flatMap
,filter
, etc…