I haven’t followed the whole topic, but I myself always wished for stored 
properties on Swift enums.

I’d like to throw an idea in the room.

How about to a two type enums? By that I mean something like this:

enum Enum : RawType, StoreType {
    case a = (rawInstance1, storeInstance1)
    case b = (rawInstance2, storeInstance2)
    case c = rawInstance3, storeInstance3 // or not tuple like?
}

let instance = Enum.a
instance.rawValue // would be rawInstance1
instance.value // would be storeInstance1
StoreType could be anything (even another two type enum).

It would be interesting to read what you thing of that simple model. Plus 
should .value be mutable? Maybe we could communicate that somehow.

Or we could simply allow tuples on enums where the first item is always the 
RawType of the enum?!



-- 
Adrian Zubarev
Sent with Airmail

Am 10. Oktober 2016 um 19:32:20, Kenny Leung via swift-evolution 
([email protected]) schrieb:

This is the way Java enumerations work.  

https://docs.oracle.com/javase/tutorial/java/javaOO/enum.html

I think it is a good model, and I think Swift enumerations should also work the 
same way.

An enumeration is a finite set of things. It’s really inconvenient to have to 
limit those things to have only a single attribute.

-Kenny


_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to