+1 as for compleax enums it really does get messy. Leave the current approach in place, though.
I'm not sure the syntax is best though. Maybe we could just open a curly brace right after the enum case declaration and put the specific function there. Same way everything out of the braces is considered a _default_ case. On Sun, 8 Jan 2017 at 14:12 Anton Zhilin via swift-evolution < swift-evolution@swift.org> wrote: > It would be nice if for each enum case, there was a computed property > returning an optional. Then you could do: > > > enum FooBar { > > case foo(Int) > > case bar(Int) > > } > > > > let x = FooBar.foo(42) > > x.foo //=> Optional(42) > > x.bar //=> nil > > > > This feature has been discussed many times, but each time it was > considered “out of scope”. > > > > > > _______________________________________________ > > swift-evolution mailing list > > swift-evolution@swift.org > > https://lists.swift.org/mailman/listinfo/swift-evolution > >
_______________________________________________ swift-evolution mailing list swift-evolution@swift.org https://lists.swift.org/mailman/listinfo/swift-evolution