📅  最后修改于: 2022-03-11 15:01:01.329000             🧑  作者: Mango
extension Sequence where Element: Hashable {
func uniqued() -> [Element] {
var set = Set()
return filter { set.insert($0).inserted }
}
}
func foobar() {
let myUniqueArray = [1,2,4,2,1].uniqued() // => [1,2,4]
}