Skip to content

Instantly share code, notes, and snippets.

@chrislonge
Created July 21, 2019 22:34
Show Gist options
  • Save chrislonge/0c67979caa0952e3857e4b9d2655b543 to your computer and use it in GitHub Desktop.
Save chrislonge/0c67979caa0952e3857e4b9d2655b543 to your computer and use it in GitHub Desktop.
Template to conform to Hashable
import Foundation
struct MyModel: Hashable {
let identifier = UUID()
func hash(into hasher: inout Hasher) {
hasher.combine(identifier)
}
static func == (lhs: MyModel, rhs: MyModel) -> Bool {
return lhs.identifier == rhs.identifier
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment