Swift - Generic function parameter

Viewed 3263

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?

2 Answers
Related