I do have 2 different tuples of type (Double, Double):
let tuple1: (Double, Double) = (1, 2)
let tuple2: (Double, Double) = (3, 4)
I want to compare their values using a simple if statement. Something like:
if (tuple1 == tuple2) {
// Do stuff
}
This throws the following error:
Could not find an overload for '==' that accepts the supplied arguments
My current solution is a function like this:
func compareTuples <T: Equatable> (tuple1: (T, T), tuple2: (T, T)) -> Bool {
return (tuple1.0 == tuple2.0) && (tuple1.1 == tuple2.1)
}
I already tried to write an extension but can't make it work for tuples. Do you have a more elegant solution to this problem?
public func ==<A : Equatable, B : Equatable>(lhs: (A, B), rhs: (A, B)) -> Bool
– Adjacent