[swift-evolution] Request: Ability to refer to an enum case in abstract (without its associated value)

Brent Royal-Gordon brent at architechies.com
Fri Dec 11 08:24:22 CST 2015

> If you just want this for debugging, have you looked at the reflection APIs?

Sorry, that’s probably not suitable for your specific use case.

Honestly, I really do think you’re confusing two separate issues: testing which screen you’re on, and navigating to a particular screen. You can test which screen you’re on without paying attention to the specific associated values. But if you then want to navigate to a screen, you’re going to need the associated values anyway. Why would you want a version of your enum which didn’t have them?

(By the way, if your answer is “I want to map meta-enum values to the enum value I’m currently using”, then write a Hashable conformance which ignores the associated values. Then looking up .Foo(a) in a Dictionary will give you .Foo(b) if that’s present instead.)

Brent Royal-Gordon

More information about the swift-evolution mailing list