[swift-evolution] Request: Ability to refer to an enum case in abstract (without its associated value)
al_skipp at fastmail.fm
Fri Dec 11 06:51:24 CST 2015
I don’t think this suggestion would work in practice. It’s the equivalent of trying to construct a struct value with non-optional properties, but without providing any init parameters, it would result in an invalid value. If your proposal were possible I think it would cause trouble with pattern matching enums too. In a switch statement that expects to bind to associated values, what happens when it receives an enum that should have associated values, but they are not present?
> On 11 Dec 2015, at 04:53, Evan Maloney <emaloney at gilt.com> wrote:
> You're referring to the ability to test whether an existing enum value is of a given case regardless of the contents of its associated values. In other words, after a value has been created, you can test for whether it is of a specific case while ignoring any associated values.
> I'm talking about the ability to create a value that represents the generic concept of an enum case that has associated values, but without actually specifying any associated values.
> In Swift right now, you can programmatically represent an enum case that has associated values only by first supplying those associated values.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution