As the error message says, you need to make your Card
struct conform to the Equatable
protocol. Equatable
is what lets you do ==
between two items.
To conform to Equatable
, you would need to write a ==
function to tell the compiler how to test equality between two Card
s.
HOWEVER, since Card
's two properties are Int
and String
, which are already Equatable
, you don’t need to do anything to make Card
itself Equatable
except this:
struct Card: Equatable {
var cnumb:Int
var suit:String
}
The compiler is able to synthesize Equatable
conformance for you if all the properties are themselves Equatable
once you tell it to do so.