Created
April 19, 2020 16:52
-
-
Save FabP93/1a6b3c1b109a112c0a85d48953d19c52 to your computer and use it in GitHub Desktop.
Hashable in swift 1
This file contains 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
/// 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