> enum Suit: Int {
> case Hearts, Spades, Diamonds, Clubs
>
> static var all: Suit[] { return [ Hearts, Spades, Diamonds, Clubs ] }
>
> var description: String {
> return match(self) {
> case .Hearts: "♥️"
> case .Spades: "♠️"
> case .Diamonds: "♦️"
> case .Clubs: "♣️"
> }
> }
>
> var isRed: Bool {
> return match(self) {
> case .Hearts, .Diamonds: true
> case .Spades, .Clubs: false
> }
> }
> }
This attacks the `return` boilerplate rather than the `switch` boilerplate.
That means that, while it helps in this case, it would not help with members
which have complicated logic or side effects. (And technically, the boilerplate
is still there—it's just a `match(self)` instead of a `switch self`. I feel
like they're orthogonal issues.
--
Brent Royal-Gordon
Architechies
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution