我是新手,并且正在阅读教程以了解更多信息。
在以下代码中,我定义了自定义运算符(<和==),但是代码工作正常,但是Xcode在代码的第一行显示了这些错误。
Type 'SuitedCard' does not conform to protocol 'Equatable'
Type 'SuitedCard' does not conform to protocol 'Comparable'
Run Code Online (Sandbox Code Playgroud)
这是代码:
struct SuitedCard: Equatable, Comparable {
// a card can be ??, ??, ??, ??
enum Suit {
case hearts
case spades
case diamonds
case clubs
}
// the possible values of a card
enum Value: Int {
case two = 2
case three = 3
case four = 4
case five = 5
case six = 6
case seven = 7 …Run Code Online (Sandbox Code Playgroud)