Created
May 23, 2016 11:43
-
-
Save buddax2/581997eaca925f5311c8f40060664889 to your computer and use it in GitHub Desktop.
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 Array where Element: ComparisonProtocol { | |
func unique() -> [Element] { | |
var uniqVals2: Set<String> = [] | |
return self.filter { | |
guard let comparisonAttribute = $0.comparisonAttribute else { return false } | |
if uniqVals2.contains(comparisonAttribute) == false { | |
uniqVals2.insert(comparisonAttribute) | |
return true | |
} | |
return false | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment