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
Post a Comment