[swift-evolution] Dotless case names in switch cases

肇鑫 owenzx at gmail.com
Fri Jan 15 17:38:42 CST 2016


let Foo:SomeEnum = .Bar
let Bar:SomeEnum = .Foo

enum SomeEnum {
    case Foo
    case Bar
    func demoDotAndNoDot() {
        switch self {
        case .Foo: print("This has the usual dot before the case name.")
        case .Bar: print("This has no dot, which is ok, at least in this
particular context.")
        }
    }
}

above code works in current Swift. It will not work after your changes.

zhaoxin

On Sat, Jan 16, 2016 at 6:44 AM, Jens Persson via swift-evolution <
swift-evolution at swift.org> wrote:

> enum SomeEnum {
>     case Foo
>     case Bar
>     func demoDotAndNoDot() {
>         switch self {
>         case .Foo: print("This has the usual dot before the case name.")
>         case Bar: print("This has no dot, which is ok, at least in this
> particular context.")
>         }
>     }
> }
>
> I'm just throwing this out in case someone should feel like writing a
> formal proposal to remove the dotless form.
>
> I'd be ok with removing it since it only works in some specific contexts.
>
> /Jens
>
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>


-- 

Owen Zhao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160116/01d5b014/attachment.html>


More information about the swift-evolution mailing list