Blog

Removing duplicate elements from a Swift array

Lammert Westerhoff

Updated April 30, 2025
1 minute

Today I had to remove duplicate items from an Array while maintaining the original order. I knew there was no standard uniq function in Swift so I Googled a bit and found some implementations on StackOverflow. I found some good implementations, but wasn’t completely satisfied with any of them. So of course I tried to see if I could make something myself that I would be satisfied with.

Written by

Lammert Westerhoff