Removing duplicates from an array!

There are several ways to remove duplicates from an array. In this article, I will cover two of them.

The first example is with the use of a Set. This is because the set collection only allows for unique elements.

The issue with this method is that the order of the array will be disregarded.

Another better way is to use Swift’s extension feature.

So we have kept the order of the array and quickly removed any duplicates.