<html><head></head><body>In what way?<br><br><br><br><br>
<div class="gmail_quote">On Sun, Apr 17, 2016 at 3:53 PM -0700, "Howard Lovatt" <span dir="ltr"><<a href="mailto:howard.lovatt@gmail.com" target="_blank">howard.lovatt@gmail.com</a>></span> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="3D"ltr"">
I think this should be part of completing generics.<br><br>On Sunday, 17 April 2016, Yogev Sitton via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">I have a class that is conforming to a protocol with a method that requires a specific return type.<div>In case I want to return a subclass of the return type I am forced to use an associatedtype that feels like a hack.</div><div><br></div><div>As an example:</div><div><br></div><div><div><i>protocol MyShapeProtocol {</i></div><div><i> func make() -> Shape?</i></div><div><i>}</i></div><div><i><br></i></div><div><i>class Circle : Shape {}</i></div><div><i><br></i></div><div><i>class CircleMaker : MyShapeProtocol{</i></div><div><i> func make() -> Circle? {</i></div><div><i> return Circle()</i></div><div><i> }</i></div><div><i>}</i></div></div><div><br></div><div>This will not work.</div><div>For that to work I’ll need to use toe associatedtype “hack”:</div><div><br></div><div><div><i>protocol MyShapeProtocol {</i></div><div><i> associatedtype ShapeReturnType : Shape</i></div><div><i> func make() -> ShapeReturnType?</i></div><div><i>}</i></div><div><i><br></i></div><div><div><i>class Circle : Shape {}</i></div></div><div><i><br></i></div><div><i>class CircleMaker : MyShapeProtocol{</i></div><div><i> func make() -> Circle? {</i></div><div><i> return Circle()</i></div><div><i> }</i></div><div><i>}</i></div></div><div><br></div><div>Is there a real value in adding the associatedtype line?</div></div></blockquote><br><br>-- <br>-- Howard.<br>
</div>
</blockquote>
</div>
</body></html>