I am trying to do this:
protocol Fly {
}
class Bird: Fly {
}
func fetch<T: Fly>(model: T) {
print("Done")
}
let bird: Fly = Bird()
fetch(model: bird)
However I get this error:
Cannot invoke 'fetch' with an argument list of type '(model: Fly)'
I set let bird: Fly = Bird() to be of type Fly, shouldn't it work since the function fetch takes any object that conforms to that protocol?
Any thoughts?
func fetch<T>(model: T) where T: Fly. What you have typed is for subclassing I believe. But still it shows same error.func fetch(model: Fly)That will work fine,