As to the why question: (just guessing here)

By the time the compiler want to know what type will be in the array, it cannot 
do so. The enum is a generic and thus without full type information (it only 
has partial type information).

Regards,
Rien

Site: http://balancingrock.nl
Blog: http://swiftrien.blogspot.com
Github: http://github.com/Swiftrien
Project: http://swiftfire.nl




> On 29 Dec 2016, at 00:41, Brandon Knope via swift-users 
> <swift-users@swift.org> wrote:
> 
> I don’t understand why this is a problem
> 
> protocol Element {
>     
> }
> 
> enum ElementNode<T: Element> {
>     case element(T)
>     case empty
> }
> 
> var childElements = [ElementNode<Element>]()
> 
> I need to represent an array of my nodes that could be multiple kinds of 
> elements
> 
> Is there a workaround?
> 
> Brandon
> _______________________________________________
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to