swift - Type override in generic protocol giving "explicitly specify the generic arguments to fix this issue" error -


i trying change default associated type string. getting error

explicitly specify generic arguments fix issue.

below code works fine type int not string. missing something?

//override/change associated type of protocol  protocol familiable{     associatedtype familytype = int     func getname()->[familytype] }  class numberfamily:familiable{      func getname() -> [int] {         return [1,2,3,4,5]     } }  let numref = numberfamily() print(numref.getname()) type(of: numref)  struct normalfamily<t:expressiblebystringliteral>: familiable{      func getname() -> [t] {         return ["name1","name2"]     }  }  let normalref = normalfamily() normalref.getname()  


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -