Skip to content

Instantly share code, notes, and snippets.

@soffes
Last active September 11, 2024 14:15
Show Gist options
  • Save soffes/b085c108f9ad1c804a13 to your computer and use it in GitHub Desktop.
Save soffes/b085c108f9ad1c804a13 to your computer and use it in GitHub Desktop.
Add Equatable to CLLocationCoordinate2D
import CoreLocation
extension CLLocationCoordinate2D: Equatable {}
public func ==(lhs: CLLocationCoordinate2D, rhs: CLLocationCoordinate2D) -> Bool {
return lhs.latitude == rhs.latitude && lhs.longitude == rhs.longitude
}
@soffes
Copy link
Author

soffes commented Feb 1, 2022

@x4m3 thanks! Added the import :)

@soffes
Copy link
Author

soffes commented Feb 1, 2022

Should probably update the float equality to use .ulpOfOne instead of == at some point

@codrut-cegeka
Copy link

Should probably update the float equality to use .ulpOfOne instead of == at some point

made me curious about ulp. it's actually the difference to the next representable number, and is not a good equality indicator (ex 0.5 and 0.6 both have the same ulp, 1.1102230246251565e-16 for double and 5.9604645e-08 for float

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment