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

Reply via email to