<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(34, 36, 38); font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">Hello there!</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(34, 36, 38); font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(34, 36, 38); font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255);" class="">I have the following class with a generic factory method:</span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">final</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">class</span> Something<T> {</div><p style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> value: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span></div><p style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">init</span>(initial: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">T</span>) {</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">value</span> = initial</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> }</div><p style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class="">extension<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Something</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> {</span></div><p style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">class</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">func</span> zip<A, B>(a: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">A</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">_</span> b: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">B</span>) -> <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Something</span><(<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">A</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">B</span>)> {</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> initial = (a, b)</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Something</span><(<span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">A</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">B</span>)>(initial: initial)</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""> }</div><p style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""> <br class="webkit-block-placeholder"></p><div style="margin: 0px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; min-height: 14px;" class=""><span style="background-color: rgb(255, 255, 255);" class=""><font color="#222426" face="Arial, Helvetica Neue, Helvetica, sans-serif" size="2" class="">How come I can’t call </font></span><span style="font-family: Menlo;" class="">zip</span><span style="background-color: rgb(255, 255, 255);" class=""><font color="#222426" face="Arial, Helvetica Neue, Helvetica, sans-serif" size="2" class=""> without explicitly specifying return type?</font></span></div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// ERROR: Cannot invoke `zip` with an argument list of type `(Int, Int)`</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> y = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Something</span>.zip(<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span>)</div><div style="margin: 0px; line-height: normal; font-family: Menlo; min-height: 14px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// OK: Works but it’s unacceptable to require this on caller's side</div><div style="margin: 0px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> x = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Something</span><(<span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span>)>.<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">zip</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">1</span>, <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">2</span>)</div><div class=""><br class=""></div><div class="">Thank you for your time!</div><div class=""><br class=""></div><div class="">R+</div></body></html>