[swift-users] Generic factory method and type inference

Dmitri Gribenko gribozavr at gmail.com
Thu Mar 17 10:45:36 CDT 2016


On Thu, Mar 17, 2016 at 6:58 AM, Rudolf Adamkovič <swift-users at swift.org> wrote:
> How come I can’t call zip without explicitly specifying return type?
>
> // ERROR: Cannot invoke `zip` with an argument list of type `(Int, Int)`
> let y = Something.zip(1, 2)

The compiler can't infer T from your call.  T and (A, B) are three
separate type parameters.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-users mailing list