[swift-users] Using 'SomeProtocol' as a concrete type conforming to protocol 'SomeProtocol' is not supported

Rien Rien at Balancingrock.nl
Thu Dec 29 03:10:17 CST 2016


I think you made your type (enum) unnecessary complex, the following works:

protocol Element {
    
}

enum ElementNode {
    case element(Element)
    case empty
}

var childElements = [ElementNode]()


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 at 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 at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users



More information about the swift-users mailing list