Created
November 4, 2021 07:30
-
-
Save kaaaaai/b4b6c36e9c2177511999431c4b1e5a74 to your computer and use it in GitHub Desktop.
swift.extension.数组去重
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension Sequence where Element: Hashable { | |
func uniqued() -> [Element] { | |
var set = Set<Element>() | |
return filter { set.insert($0).inserted } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment