Can't get Swift protocol to conform - but code looks perfect to me -


the code below looks should work. error saying doesn't conform protocol, looks me conforms protocol. doing wrong?

the issue both properties need comment out both of them (in protocol) prevent error.

class myotherclass { }  class anotherclass { }  protocol myprotocol {   var type: anyclass { }   var myclosure: (text: string) -> myotherclass { } }  class myclass: myprotocol {   var type = anotherclass.self   var myclosure = {     (text: string) -> myotherclass in     return myotherclass()   } } 

the compiler reason unable guess types of properties in class. specifying types fix problem.

class myclass: myprotocol {     var type : anyclass = anotherclass.self     var myclosure : ((text: string) -> myotherclass) = { (text: string) in         return myotherclass()     } } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -