Let’s learn about removeDuplicates(). As the name suggests, it removes the duplicates. But it works in a little bit different way that you might expect. Applying removeDuplicates() — this is not what you expect let words = ["apple", "apple", "fruit", "apple", "mango", "watermelon", "apple"]
words.publisher
.removeDuplicates()
.sink {
print($0) // apple, fruit, apple, mango, watermelon, apple
}