Int conforms to Strideable byway of Integer <- SignedInteger <- Int (not exactly sure how it will be once the integer proposal is implemented but it will still be strideable).<br><br>-Shawn<br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 4, 2016 at 10:38 PM Zhao Xin via swift-users <<a href="mailto:swift-users@swift.org">swift-users@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">In Swift 3, </div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-family:'SF Mono',Menlo,monospace;font-size:14px;color:rgb(170,13,145)"><br></span></div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-family:'SF Mono',Menlo,monospace;font-size:14px;color:rgb(170,13,145)">func</span><span style="font-family:'SF Mono',Menlo,monospace;color:rgb(51,51,51);font-size:14px;background-color:rgb(250,250,250)"> </span><span style="font-family:'SF Mono',Menlo,monospace;font-size:14px;color:rgb(0,0,0)">stride</span><span style="font-family:'SF Mono',Menlo,monospace;color:rgb(51,51,51);font-size:14px;background-color:rgb(250,250,250)"><</span><span style="font-family:'SF Mono',Menlo,monospace;font-size:14px;color:rgb(0,0,0)">T</span><span style="font-family:'SF Mono',Menlo,monospace;color:rgb(51,51,51);font-size:14px;background-color:rgb(250,250,250)"> : </span><span style="font-family:'SF Mono',Menlo,monospace;font-size:14px;color:rgb(92,38,153)"><a style="color:rgb(92,38,153);text-decoration:none">Strideable</a></span><span style="font-family:'SF Mono',Menlo,monospace;color:rgb(51,51,51);font-size:14px;background-color:rgb(250,250,250)">>(</span><span style="font-family:'SF Mono',Menlo,monospace;font-size:14px;color:rgb(0,0,0)">from</span><span style="font-family:'SF Mono',Menlo,monospace;color:rgb(51,51,51);font-size:14px;background-color:rgb(250,250,250)"> </span><span style="font-family:'SF Mono',Menlo,monospace;color:rgb(51,51,51);font-size:14px">start</span><span style="font-family:'SF Mono',Menlo,monospace;color:rgb(51,51,51);font-size:14px;background-color:rgb(250,250,250)">: T, </span><span style="font-family:'SF Mono',Menlo,monospace;font-size:14px;color:rgb(0,0,0)">to</span><span style="font-family:'SF Mono',Menlo,monospace;color:rgb(51,51,51);font-size:14px;background-color:rgb(250,250,250)"> </span><span style="font-family:'SF Mono',Menlo,monospace;color:rgb(51,51,51);font-size:14px">end</span><span style="font-family:'SF Mono',Menlo,monospace;color:rgb(51,51,51);font-size:14px;background-color:rgb(250,250,250)">: T, </span><span style="font-family:'SF Mono',Menlo,monospace;font-size:14px;color:rgb(0,0,0)">by</span><span style="font-family:'SF Mono',Menlo,monospace;color:rgb(51,51,51);font-size:14px;background-color:rgb(250,250,250)"> </span><span style="font-family:'SF Mono',Menlo,monospace;color:rgb(51,51,51);font-size:14px">stride</span><span style="font-family:'SF Mono',Menlo,monospace;color:rgb(51,51,51);font-size:14px;background-color:rgb(250,250,250)">: T.Stride) -> </span><span style="font-family:'SF Mono',Menlo,monospace;font-size:14px;color:rgb(92,38,153)"><a style="color:rgb(92,38,153);text-decoration:none">StrideTo</a></span><span style="font-family:'SF Mono',Menlo,monospace;color:rgb(51,51,51);font-size:14px;background-color:rgb(250,250,250)"><T></span></div><div class="gmail_default" style="font-family:georgia,serif"><span style="font-family:'SF Mono',Menlo,monospace;color:rgb(51,51,51);font-size:14px;background-color:rgb(250,250,250)"><br></span></div><div class="gmail_default"><font color="#333333" face="SF Mono, Menlo, monospace"><span style="background-color:rgb(250,250,250)">Int does not </span>conform to Strideable. </font></div><div class="gmail_default"><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><br></span></font></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_default"><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><div class="gmail_default">Adopted By</div></span></font></div><div class="gmail_default"><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><div class="gmail_default"><br></div></span></font></div><div class="gmail_default"><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><div class="gmail_default">CGFloat</div></span></font></div><div class="gmail_default"><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><div class="gmail_default">Decimal</div></span></font></div><div class="gmail_default"><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><div class="gmail_default">Double</div></span></font></div><div class="gmail_default"><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><div class="gmail_default">Float</div></span></font></div><div class="gmail_default"><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><div class="gmail_default">Float80</div></span></font></div><div class="gmail_default"><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><div class="gmail_default">String.UTF16View.Index</div></span></font></div><div class="gmail_default"><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><div class="gmail_default">UnsafeMutablePointer</div></span></font></div><div class="gmail_default"><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><div class="gmail_default">UnsafePointer</div><div class="gmail_default"><br></div></span></font></div></blockquote><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><div class="gmail_default" style="font-family:georgia,serif;display:inline">In Swift 2.2,</div></span></font><div><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><div class="gmail_default" style="font-family:georgia,serif;display:inline"><br></div></span></font></div><div><span style="background-color:transparent;border:0px;font-size:12px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145);font-family:Menlo,monospace">@warn_unused_result</span><span style="color:rgb(0,0,0);font-family:Menlo,monospace;font-size:12px"> </span><span style="background-color:transparent;border:0px;font-size:12px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(170,51,145);font-family:Menlo,monospace">func</span><span style="color:rgb(0,0,0);font-family:Menlo,monospace;font-size:12px"> </span><span style="background-color:transparent;border:0px;font-size:12px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,0,0);font-family:Menlo,monospace">stride</span><span style="color:rgb(0,0,0);font-family:Menlo,monospace;font-size:12px">(</span><span style="background-color:transparent;border:0px;font-size:12px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,0,0);font-family:Menlo,monospace">to</span><span style="color:rgb(0,0,0);font-family:Menlo,monospace;font-size:12px"> </span><code style="background-color:transparent;border:0px;font-size:12px;margin:0px 0px 15px;outline:0px;padding:0px 0px 6px;vertical-align:baseline;color:rgb(0,0,0);font-family:Menlo,monospace;word-wrap:break-word"><em style="background-color:transparent;border:0px;font-size:0.92307em;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(65,65,65);line-height:1.5">end</em></code><span style="color:rgb(0,0,0);font-family:Menlo,monospace;font-size:12px">: </span><span style="background-color:rgb(255,255,255);border:0px;font-size:12px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(92,38,153);font-family:Menlo,monospace">Self</span><span style="color:rgb(0,0,0);font-family:Menlo,monospace;font-size:12px">, </span><span style="background-color:transparent;border:0px;font-size:12px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(0,0,0);font-family:Menlo,monospace">by</span><span style="color:rgb(0,0,0);font-family:Menlo,monospace;font-size:12px"> </span><code style="background-color:transparent;border:0px;font-size:12px;margin:0px 0px 15px;outline:0px;padding:0px 0px 6px;vertical-align:baseline;color:rgb(0,0,0);font-family:Menlo,monospace;word-wrap:break-word"><em style="background-color:transparent;border:0px;font-size:0.92307em;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(65,65,65);line-height:1.5">stride</em></code><span style="color:rgb(0,0,0);font-family:Menlo,monospace;font-size:12px">: </span><span style="background-color:rgb(255,255,255);border:0px;font-size:12px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(92,38,153);font-family:Menlo,monospace">Self</span><span style="color:rgb(0,0,0);font-family:Menlo,monospace;font-size:12px">.</span><span style="background-color:rgb(255,255,255);border:0px;font-size:12px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(92,38,153);font-family:Menlo,monospace">Stride</span><span style="color:rgb(0,0,0);font-family:Menlo,monospace;font-size:12px">) -> </span><span style="background-color:rgb(255,255,255);border:0px;font-size:12px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(92,38,153);font-family:Menlo,monospace"><a style="background-color:transparent;border:0px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:inherit;text-decoration:none">StrideTo</a></span><span style="color:rgb(0,0,0);font-family:Menlo,monospace;font-size:12px"><</span><span style="background-color:rgb(255,255,255);border:0px;font-size:12px;margin:0px;outline:0px;padding:0px;vertical-align:baseline;color:rgb(92,38,153);font-family:Menlo,monospace">Self</span><span style="color:rgb(0,0,0);font-family:Menlo,monospace;font-size:12px">></span></div><div><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><div class="gmail_default" style="font-family:georgia,serif;display:inline"><br></div></span></font></div><div><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><div class="gmail_default" style="font-family:georgia,serif;display:inline">It uses Self, which means the type of the variable, instead of T.</div></span></font></div><div><div class="gmail_default"><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px"><br></span></font></div><div class="gmail_default"><font color="#333333" face="SF Mono, Menlo, monospace"><span style="font-size:14px">Zhaoxin</span></font></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 5, 2016 at 11:41 AM, Adriano Ferreira via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> 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"><div>Hi everyone!</div><div><br></div><div>I’m converting some code to Swift 3 and got this issue?</div><div><br></div><div><br></div><div><img height="95" width="822" src="cid:F1CDA6A7-3329-4C33-BFCE-A8233FEEAE2E@home"></div><div><br></div><div><br></div><div>Does anybody know what’s going on?</div><div><br></div><div>Here’s the code, before and after conversion:</div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><div style="font-family:Helvetica;font-size:12px"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(0,132,0)">// Swift 2.2</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)"><span>extension</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(112,61,170)">Int</span><span style="color:rgb(0,0,0)"> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br><span></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"> </span><span>// Repeat a block of code from `self` up to a limit</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(187,44,162)">func</span><span> up(to upper: </span><span style="color:rgb(112,61,170)">Int</span><span>, by step: </span><span style="color:rgb(112,61,170)">Int</span><span> = </span><span style="color:rgb(39,42,216)">1</span><span>, </span><span style="color:rgb(187,44,162)">@noescape</span><span> closure:</span><span> () -> </span><span style="color:rgb(112,61,170)">Void</span><span>) {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span></span><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(187,44,162)">for</span><span> </span><span style="color:rgb(187,44,162)">_</span><span> </span><span style="color:rgb(187,44,162)">in</span><span> <span style="color:rgb(187,44,162)">self</span><span>.</span>stride(</span><span>to: upper, by: step) {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> closure()</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>}</span></div><div><span><br></span></div><div><span><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(0,132,0)">// Swift 3</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)"><span>extension</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(112,61,170)">Int</span><span style="color:rgb(0,0,0)"> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><br><span></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span style="color:rgb(0,0,0)"> </span><span>// Repeat a block of code from `self` up to a limit</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(187,44,162)">func</span><span> up(to upper: </span><span style="color:rgb(112,61,170)">Int</span><span>, by step: </span><span style="color:rgb(112,61,170)">Int</span><span> = </span><span style="color:rgb(39,42,216)">1</span><span>, </span><span style="color:rgb(187,44,162)">_</span><span> closure: </span><span style="color:rgb(187,44,162)">@noescape</span><span> () -> </span><span style="color:rgb(112,61,170)">Void</span><span>) {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;min-height:13px"><span></span><br></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:rgb(187,44,162)">for</span><span> </span><span style="color:rgb(187,44,162)">_</span><span> </span><span style="color:rgb(187,44,162)">in</span><span> stride(from: </span><span style="color:rgb(187,44,162)">self</span><span>, to: upper, by: step) {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> closure()</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>}</span></div></div><div><span><br></span></div></span></div><div><span><br></span></div><div><span><span style="color:rgb(0,132,0);font-family:Menlo;font-size:11px">// Usage</span></span></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#272ad8">1</span><span>.</span><span style="color:#31595d">up</span><span>(to: </span><span style="color:#272ad8">10</span><span>, by: </span><span style="color:#272ad8">2</span><span>) {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span> </span><span style="color:#3d1d81">print</span><span>(</span><span style="color:#d12f1b">"Hi!"</span><span>)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span>}</span></div></div></div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span><br></span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-family:Helvetica;font-size:12px">Best,</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="font-family:Helvetica;font-size:12px"><br></span></div><div style="margin:0px;line-height:normal">— A</div></div><br>_______________________________________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-users</a><br>
</blockquote></div>