草庐IT

MyAssociatedValue

全部标签

swift 3 : Converting enum case with associated value to closure with protocol parameter results in a compiler error

我有一个枚举,其关联值为结构。当我编写这段代码时,它编译没有错误:protocolMyProtocol{}structMyAssociatedValue:MyProtocol{}enumMyEnum{casemyCase(MyAssociatedValue)}funcmyEnumClosureMapping()->(MyAssociatedValue)->MyEnum{returnMyEnum.myCase}但是我添加了另一个这样的函数:funcmySecondEnumClosureMapping()->(MyProtocol)->MyEnum{returnMyEnum.myCase}