Suit.parse constructor
Suit.parse(
- String value
Parses a char (1-charactor-length string) and returns a Suit. The value must be one of "s"
, "h"
, "d"
or "c"
.
assert(Suit.parse("s") == Suit.spade);
assert(Suit.parse("c") == Suit.club);
If any string else is given, this throws a SuitParseFailureException.
Suit.parse("sc"); // throws SuitParseFailureException
Suit.parse("S"); // throws SuitParseFailureException
Implementation
factory Suit.parse(String value) {
switch (value) {
case 's':
return Suit.spade;
case 'h':
return Suit.heart;
case 'd':
return Suit.diamond;
case 'c':
return Suit.club;
default:
throw SuitParseFailureException(value: value);
}
}