Swift Retirez tous les doublons d'un tableau
extension Sequence where Element: Hashable {
func uniqued() -> [Element] {
var set = Set<Element>()
return filter { set.insert($0).inserted }
}
}
func foobar() {
let myUniqueArray = [1,2,4,2,1].uniqued() // => [1,2,4]
}
TheKrisinator