yattee/Extensions/Sequence+Unique.swift
2022-08-15 16:34:20 +02:00

9 lines
219 B
Swift

import Foundation
extension Sequence where Iterator.Element: Hashable {
func unique() -> [Iterator.Element] {
var seen: Set<Iterator.Element> = []
return filter { seen.insert($0).inserted }
}
}