Hi
I have the following code, where Suit and CardNumber are enum: Int types:
enum Card: CustomStringConvertible /, Equatable */ {
case suitCard(Suit, CardNumber)
case redjoker, blackjoker
static func ==(lhs: Card, rhs: Card) -> Bool
{
switch lhs {
case let .suitCard(lsuit, lnumber):
switch rhs {
case let .suitCard(rsuit, rnumber):
return lsuit == rsuit && lnumber == rnumber
default: return false
}
case .redjoker:
return rhs == .redjoker
case .blackjoker:
return rhs == .redjoker
}
}/
}// Card
and when I call:
if Card.blackjoker == Card.redjoker {
print("Hello")
}
it starts going into recursion and blows the stack. It works in most cases, i.e. where the .suitCard option is selected. But on the simple cases, it seems to need some sort of super.== call, but that doesn't work: it encounters an == and calls itself, to find itself back in the same function.
What are we supposed to do at this point?
TIA
Mark