I want to pass the type of my struct ("myStruct") to my function ("testFunc") which is bound by a protocol ("TestProtocol")
protocol TestProtocol {
func getName() -> String
}
func testFunc <T: TestProtocol> (with type: T) {
print ("testFunc")
}
struct myStruct: TestProtocol {
var name: String
func getName() -> String {
return name
}
}
testFunc(with: myStruct.self)
But I get the error that myStruct.Type does not conform to TestProtocol; yet it clearly does!