Skip to content

Instantly share code, notes, and snippets.

@FabP93
Created April 19, 2020 16:52
Show Gist options
  • Save FabP93/1a6b3c1b109a112c0a85d48953d19c52 to your computer and use it in GitHub Desktop.
Save FabP93/1a6b3c1b109a112c0a85d48953d19c52 to your computer and use it in GitHub Desktop.
Hashable in swift 1
/// A point in an x-y coordinate system.
struct GridPoint {
var x: Int
var y: Int
}
extension GridPoint: Hashable {
static func == (lhs: GridPoint, rhs: GridPoint) -> Bool {
return lhs.x == rhs.x && lhs.y == rhs.y
}
var hashValue: Int {
return x ^ y
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment