Skip to content

Instantly share code, notes, and snippets.

@soffes
Last active October 4, 2023 18:50
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • 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
}
@deadbaed
Copy link

deadbaed commented Feb 1, 2022

Thank you for this snippet! Exactly what I was looking for!

A little suggestion: add import MapKit at the top of the file to be able to use the file as is :)

Cheers!

@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

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