Skip to content

Instantly share code, notes, and snippets.

@buddax2
Created May 23, 2016 11:43
Show Gist options
  • Save buddax2/581997eaca925f5311c8f40060664889 to your computer and use it in GitHub Desktop.
Save buddax2/581997eaca925f5311c8f40060664889 to your computer and use it in GitHub Desktop.
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