Created
May 4, 2017 14:18
-
-
Save DonMag/c4f612c5ddfc886ef8cad18de28c5e0b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| struct PlanPoint: Equatable { | |
| var x, y: Int | |
| } | |
| func == (left: PlanPoint, right: PlanPoint) -> Bool { | |
| return left.x == right.x && left.y == right.y | |
| } | |
| private var points: Array<PlanPoint> = [] | |
| points.append(PlanPoint(x: 2, y: 1)) | |
| points.append(PlanPoint(x: 2, y: 2)) | |
| points.append(PlanPoint(x: 2, y: 3)) | |
| points.append(PlanPoint(x: 2, y: 4)) | |
| points.append(PlanPoint(x: 2, y: 5)) | |
| points.append(PlanPoint(x: 2, y: 6)) | |
| let p = PlanPoint(x: 2, y: 3) | |
| print(points) | |
| if let n = points.index(of: p) { | |
| points.remove(at: n) | |
| } | |
| print(points) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment