[swift-evolution] [Discussion] Enum Leading Dot Prefixes

David Waite david at alkaline-solutions.com
Fri Feb 12 12:24:57 CST 2016


I think you may have misunderstood - I’m asking if we can make your switch example into legal code :-)

var point = CGPoint.zero

switch point {
case .zero: // Error: Enum case 'zero' not found in type 'CGPoint'

-DW

> On Feb 12, 2016, at 10:57 AM, Jordan Rose <jordan_rose at apple.com> wrote:
> 
> 
>> On Feb 11, 2016, at 22:27 , David Waite via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> Would it be worthwhile to expand this (or create another proposal) to deal with switch cases only allowing dot syntax for use with enum cases?
> 
> I would be against that. I like being able to use static members with shorthand.
> 
> textField.font = .systemFontOfSize(48)
> 
> switch point {
> case .zero:
>   print("origin")
> case _ where point.x < 0:
>   print("negative x")
> default:
>   print("uninteresting")
> }
> 
> Jordan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160212/db7531d7/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160212/db7531d7/attachment.sig>


More information about the swift-evolution mailing list