Created
December 14, 2022 04:47
-
-
Save hechen/c311adbf192a07b9ad6f3ddef948c610 to your computer and use it in GitHub Desktop.
This file contains 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
/// Taken from here: https://stackoverflow.com/a/46354989/491239 | |
public | |
extension Array where Element : Hashable { | |
static func removeDuplicates(_ elements: [Element]) -> [Element] { | |
var seen = Set<Element>() return elements.filter { seen.insert($0).inserted } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment