<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 15, 2017, at 7:33 PM, Nicholas Maccharoli &lt;<a href="mailto:nmaccharoli@gmail.com" class="">nmaccharoli@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">Right, there were a few things missing!</div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">Thanks so much for pointing them out everyone.</div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br class=""></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">Dave - Great idea! I have updated the motivation section section as you suggested!</div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br class=""></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">Neil - Yes I also think the wording could be a bit better but since the word `clamped` is already being used&nbsp;</div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; I thought I would keep it consistent.&nbsp;</div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br class=""></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">Sean - Looks as if its a term of art to me as well.&nbsp;</div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br class=""></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">Nate,</div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br class=""></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">Good catch! Yes I also thing clamping on an empty range should be a fatal error as well.</div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">An empty range is impossible to create with `ClosedRange` so I left the implementation&nbsp;</div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">of that alone, but it is possible with `Range` so I updated the extension on `Strideable` like so:</div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br class=""></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><pre style="box-sizing:border-box;font-family:sfmono-regular,consolas,&quot;liberation mono&quot;,menlo,courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(246,248,250);border-radius:3px;word-break:normal;color:rgb(36,41,46)" class=""><span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">extension</span> <span class="gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Strideable</span></span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">where</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Stride</span><span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> <span class="gmail-pl-e" style="box-sizing:border-box;color:rgb(121,93,163)"><span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Integer</span></span> {
    <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">func</span> <span class="gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">clamped</span>(<span class="gmail-pl-en" style="box-sizing:border-box;color:rgb(121,93,163)">to</span> <span class="gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">range</span>: <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Range</span>&lt;<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Self</span>&gt;) <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">-&gt;</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">Self</span> {
        <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> range.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">isEmpty</span> { <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">fatalError</span>(<span class="gmail-pl-s" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="gmail-pl-pds" style="box-sizing:border-box">"</span>Can't form Range with upperBound &lt; lowerBound<span class="gmail-pl-pds" style="box-sizing:border-box">"</span></span>) }
        <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">return</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">clamped</span>(<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">to</span>: range.<span class="gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">lowerBound</span><span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">...</span>(range.<span class="gmail-pl-smi" style="box-sizing:border-box;color:rgb(51,51,51)">upperBound</span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93)">-</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179)">1</span>))
    }
}</pre></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br class=""></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br class=""></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br class=""></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">Jaden,</div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)"><br class=""></div><div class="gmail_default" style="font-family:&quot;comic sans ms&quot;,sans-serif;color:rgb(39,78,19)">Yeah I think a simple `if` check would work as well.</div></div></div></blockquote><div><br class=""></div><div>I would suggest using guard. It is more idiomatic Swift for something that “fails out”.</div><div><br class=""></div><div>Also, I think this is a bad error message. The `Range` was already created! There was no problem forming it. It was passed as the argument, no problem at all. The problem is trying to *clamp* to an empty range, not forming an empty range. I would rephrase it to say something like "Cannot clamp to an empty range”. No reason to redefine what an empty range is by mentioning `upperBound &lt; lowerBound`.</div><div><br class=""></div><div>Cheers,</div><div>Jaden Geller</div></div></body></html>