> On Mar 23, 2016, at 5:13 AM, Brent Royal-Gordon via swift-evolution > <[email protected]> wrote: > > * Allow you to attach member definitions to particular cases. It would be an > error if they didn't all define the same members, unless there was a > top-level catchall. > > enum Suit: Int { > var isRed: Bool { return false } > > case Hearts { > let description: String { return "♥️" } > let isRed: Bool { return true } > } > case Spades { > let description: String { return "♠️" } > } > case Diamonds { > let description: String { return "♦️" } > let isRed: Bool { return true } > } > case Clubs { > let description: String { return "♣️" } > } > > static var all = [ Hearts, Spades, Diamonds, Clubs ] > }
Oh my, I absolutely *love this.* This would be a godsend for making ErrorType enums that bridge nicely to NSErrors, with code and userInfo properties attached to each case. +1. Charles
_______________________________________________ swift-evolution mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-evolution
