Xcode 7.0: Expose Associated Data for Enums as Tuples
Originator: | owensd | ||
Number: | rdar://22704262 | Date Originated: | 15-Sep-2015 10:41 AM |
Status: | Open | Resolved: | |
Product: | Developer Tools | Product Version: | Xcode 7.0 (7A218) |
Classification: | UI/Usability | Reproducible: | Always |
The associated data for enum cases is already tuple, I think it would a lot more consistency to Swift if it were exposed as a type. For example: enum Token { case Keyword(keyword: String, offset: Int) case Identifier(identifier: String, offset: Int) } To get the values from the cases, it should be as simple as this: let keyword /* : String? */ = importkey.Keyword?.keyword This also could address the cumbersome case matching syntax for enums vs. tuples: if case ("import", _) = importkey.Keyword { print("import keyword") } vs. today’s if case Token.Keyword("import", _) = importkey { print("import keyword") }
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!