Skip to content

Instantly share code, notes, and snippets.

@dvlprliu
Created August 5, 2016 09:47
Show Gist options
  • Save dvlprliu/ede54918e8ce48d575324bdec7886526 to your computer and use it in GitHub Desktop.
Save dvlprliu/ede54918e8ce48d575324bdec7886526 to your computer and use it in GitHub Desktop.
protocol Identifiable {
associatedtype Identifier: Equatable
var id: Identifier { get }
}
extension CollectionType where Generator.Element: Identifiable {
func indexOf(element: Self.Generator.Element) -> Self.Index? {
return self.indexOf { $0.id == element.id }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment