<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><blockquote type="cite" class=""><div class=""><div class="gmail_extra" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><div class="">I might be missing something, but you can do this already. 'case .CaseWithPayload:' matches any CaseWithPayload regardless of its payload.</div><div class=""><br class=""></div><div class="">-Joe</div></div></div></blockquote></div></div></div></blockquote></div></div></blockquote></div><br class=""><div class="">Hi Joe,</div><div class=""><br class=""></div><div class="">Thanks for the reply.</div><div class=""><br class=""></div><div class="">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, <i class="">after</i> a value has been created, you can test for whether it is of a specific case while ignoring any associated values.</div><div class=""><br class=""></div><div class=""><div class="">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.</div></div><div class=""><br class=""></div><div class="">In Swift right now, you can programmatically represent an enum case that has associated values <i class="">only&nbsp;by first supplying those associated values</i>.</div><div class=""><br class=""></div><div class="">I think of it like the difference between a class and an instance. A class defines a type <i class="">and</i> it defines storage. An instance is <i class="">of</i>&nbsp;a certain type and puts specific values in the storage. An instance or value is a <i class="">realization</i> of a class or type. If I have an instance or value, I can ask it to tell me its type. I can store that type in a variable. There is also a notation to allow me to specify any such type as a literal.</div><div class=""><br class=""></div><div class="">Just as I can programmatically refer to the type of an value (or the class of an object instance), I'd like to be able to refer to a&nbsp;case in the abstract&nbsp;<i class="">without also needing to supply associated values. </i>&nbsp;But that's not possible; an enum case that is declared with associated values can't exist in any form unless and until those values are specified.</div><div class=""><br class=""></div><div class="">Perhaps an example will help. Assume the following enum representing the universe of screens that can be displayed in an app:</div><div class=""><br class=""></div><div class="">enum Screens</div><div class="">{</div><div class="">&nbsp; &nbsp; case Splash</div><div class="">&nbsp; &nbsp; case Landing</div><div class="">&nbsp; &nbsp; case UserPreferences(User)</div><div class="">&nbsp; &nbsp; case StoreView(Store)</div><div class="">&nbsp; &nbsp; case SaleView(Sale)</div><div class="">&nbsp; &nbsp; case ProductView(Product)</div><div class="">}</div><div class=""><br class=""></div><div class="">Some of the cases have associated values, some do not. The ones that have associated values represent screens that require certain input in order to display content.</div><div class=""><div class=""><br class=""></div><div class="">Now say I want to populate a debug menu that lets testers navigate anywhere in the app. I'd like a way to represent each screen in the app, but <i class="">without</i> any specific content.</div></div><div class=""><br class=""></div><div class="">I have an enum of Screens right here, but I can't actually use it for that purpose because I can't create values from it without supplying the associated values right then and there. So I can't add a "func allScreens() -&gt; [Screens]" to the enum to allow me to query for this information.</div><div class=""><br class=""></div><div class="">The simplest work-around for this use case seems to be creating a parallel enum like:</div><div class=""><br class=""></div><div class=""><div class="">enum ScreenTypes</div><div class="">{</div><div class="">&nbsp; &nbsp; case Splash</div><div class="">&nbsp; &nbsp; case Landing</div><div class="">&nbsp; &nbsp; case UserPreferences</div><div class="">&nbsp; &nbsp; case StoreView</div><div class="">&nbsp; &nbsp; case SaleView</div><div class="">&nbsp; &nbsp; case ProductView</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; func allScreens() -&gt; [ScreenTypes]</div><div class="">}</div></div><div class=""><br class=""></div><div class="">With such an enum, I <i class="">could</i>&nbsp;populate a debug menu.</div><div class=""><br class=""></div><div class=""><div class="">Several times now when I've used enums that have associated values, I've wished for a parallel enum that had the same cases, but without associated values, so I could do things like that. I usually end of creating one, but then I lose the ability to have the compiler flag a whole class of errors.</div></div><div class=""><br class=""></div><div class="">Does my explanation make sense?</div><div class=""><br class=""></div><div class="">All the best,</div><div class="">E.</div></body></html>