I have a protocol called P
, and I want to write a function that would return an instance of any type conforming to that protocol.
I wrote this:
func f<T: P>() -> T? {
// ...
}
But then when I try to call it:
var fp = f()
I get this error: Generic parameter 'T' could not be inferred
. What am I doing wrong and how to solve this?
Thanks for your help.