2
RayS99
6y

//In the code block below. What are both self methods refering to? do both self methods refer to the Suit enum because it is inside the enum block? I am trying to better understand self. Please see link for expanded question.

enum Suit {
case spades, hearts, diamonds, clubs

var rank: Int {
switch self {
case .spades: return 4
case .hearts: return 3
case .diamonds: return 2
case .clubs: return 1
}
}

func beats(_ otherSuit: Suit) -> Bool {
return self.rank > otherSuit.rank
}
}

https://code.sololearn.com/c9KIG0ab...

Comments
Add Comment