Skip to content

Commit

Permalink
Updates for Swift 5.0
Browse files Browse the repository at this point in the history
Removes unnecessary equatable implementations, since default implementations of `Equatable` has identical result.
  • Loading branch information
kelvinlauKL authored Mar 9, 2019
1 parent 7f6f5a5 commit 04b2d30
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions Points Lines Planes/Points Lines Planes/2D/Line2D.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,11 @@ struct Line2D: Equatable {
enum Slope: Equatable {
case finite(slope: Double)
case infinite(offset: Double)

static func ==(lhs: Slope, rhs: Slope) -> Bool {
switch (lhs, rhs) {
case (.finite(let slope1), .finite(let slope2)): return slope1 == slope2
case (.infinite(let offset1), .infinite(let offset2)): return offset1 == offset2
default: return false
}
}
}

enum Direction: Equatable {
case increasing
case decreasing

static func ==(lhs: Direction, rhs: Direction) -> Bool {
switch (lhs, rhs) {
case (.increasing, .increasing): return true
case (.decreasing, .decreasing): return true
default: return false
}
}
}

init(from p1: Point2D, to p2: Point2D) {
Expand Down Expand Up @@ -154,8 +138,4 @@ struct Line2D: Equatable {
return Line2D(slope: .finite(slope: 0), offset: p.y, direction: dir)
}
}

static func ==(lhs: Line2D, rhs: Line2D) -> Bool {
return lhs.slope == rhs.slope && lhs.offset == rhs.offset && lhs.direction == rhs.direction
}
}

0 comments on commit 04b2d30

Please sign in to comment.