> On May 26, 2016, at 4:47 PM, Brent Royal-Gordon via swift-evolution
> <[email protected]> wrote:
>
> - Abusing rawValue is just that: an abuse.
In addition, enums with associated types can’t have rawValues.
Why is this relevant, you may ask? Because error enums are a huge use case for
something like this. Being able to do the below would be great:
enum MyError: ErrorProtocol {
accessor var localizedFailureReason: String
accessor var url: NSURL
case FileNotFound(url: NSURL) {
self.localizedFailureReason = “File \"\(url.lastPathComponent ?? “”)\”
not found.”
self.url = url
}
case FileIsCorrupt(url: NSURL) {
self.localizedFailureReason = “File \"\(url.lastPathComponent ?? “”)\”
is corrupt.”
self.url = url
}
}
This would be much cleaner than the existing method of using a switch to create
a userInfo dictionary for creating an NSError to send to -[NSApplication
presentError:] and similar methods.
Charles
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution