I can't get comparisons (==) of enum types compiling. The following example
contract Card
{
enum Suit {Heart, Diamond, Shape, Club, Jocker}
Suit public suit;
enum Rank {Two, Three, Four, Five, Six, Seven, Eight, Nine, Ten, Jack, Queen, King, Ace, Jocker}
Rank public rank;
function equal(Card card) returns (bool)
{
return suit == card.suit && rank == card.rank;
}
}
has the following compile errors
Card.sol:11:16: Error: Operator == not compatible with types enum Suit and function () returns (enum Suit)
return suit == card.suit && rank == card.rank;
^---------------^
Card.sol:11:37: Error: Operator == not compatible with types enum Rank and function () returns (enum Rank)
return suit == card.suit && rank == card.rank;
Any ideas on how variables of an enum type can be compared?
Thanks Nick
card.suit
is a function, whilecard.suit()
should be the enum. – Karl Floersch May 8 '16 at 20:35