diff options
Diffstat (limited to 'Sora/Extensions')
| -rw-r--r-- | Sora/Extensions/Array+RemovingDuplicates.swift | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Sora/Extensions/Array+RemovingDuplicates.swift b/Sora/Extensions/Array+RemovingDuplicates.swift new file mode 100644 index 0000000..15fc697 --- /dev/null +++ b/Sora/Extensions/Array+RemovingDuplicates.swift @@ -0,0 +1,9 @@ +import Foundation + +extension Array where Element: Hashable { + func removingDuplicates() -> [Element] { + var seen = Set<Element>() + + return filter { seen.insert($0).inserted } + } +} |