[swift-evolution] Allowing enum extensions to also be able to expand case options

Edward Valentini edwardvalentini at gmail.com
Thu Jun 30 14:58:25 CDT 2016

I am finding myself in a situation where the most elegant "swifty" solution would be to allow enum extensions to add to existing case options.  For example lets say I'm using a library that has the following enum defined: 

enum MyDirection {
   case east, west

My app for example also makes use of north and south, so I would love to be able to write: 

extension MyDirection {
   case north,south

In objective c, one would probably have defined constants like MyDirectionEast etc...  these would probably have been mapped to ints or strings so a consumer of this library could have easily extended this to add additional functionality, but using constants like that is not very "swifty"

I'm curious what the swift community thinks.

Thank you 

More information about the swift-evolution mailing list