[swift-evolution] [Idea] Find alternatives to `switch self`

Patrick Smith pgwsmith at gmail.com
Wed Mar 23 19:42:14 CDT 2016


Maybe the dictionary literal syntax could be used as a shorthand?

  

enum Suit: Int {  
  case Hearts, Spades, Diamonds, Clubs  
  
  var description: String {  
    return switch self [  
      .Hearts: "♥️",  
      .Spades: "♠️",  
      .Diamonds: "♦️",  
      .Clubs: "♣️"  
    ]  
  }  
  
  var isRed: Bool {  
    return switch self [  
      .Hearts: true,  
      .Diamonds: true,  
      .Spades: false,  
      .Clubs: false  
    ]  
  }  
}  

  

  

Patrick

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160323/28da2b64/attachment.html>


More information about the swift-evolution mailing list