<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 Oct 5, 2017, at 10:58 AM, Nate Cook via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">The edge case is really the same (empty ranges), it’s about what we do with the edge case. If we include the methods on integer types, usage will look like this:<div class=""><br class=""></div><div class=""><div class=""><font face="SFMono-Regular" class="">&nbsp; &nbsp; let x = Int.random(in: 0..&lt;5) &nbsp; &nbsp; // 3<br class="">&nbsp; &nbsp;&nbsp;let y = Int.random(in: 0..&lt;0) &nbsp; &nbsp; // runtime error</font></div><div class=""><br class=""></div><div class="">If we only have the collection methods, usage will look like this:</div><div class=""><br class=""></div><div class=""><div class=""><font face="SFMono-Regular" class="">&nbsp; &nbsp; let x = (0..&lt;5).random()! &nbsp; &nbsp; &nbsp; &nbsp; // 3<br class="">&nbsp; &nbsp;&nbsp;let y = (0..&lt;0).random()! &nbsp; &nbsp; &nbsp; &nbsp; // runtime error</font></div></div></div></div></div></blockquote><br class=""></div><div>These aren’t the forms I was suggesting, what I meant was:</div><div><br class=""></div><div>extension Int {<br class="">&nbsp; init(randomInRange: Countable{Closed}Range&lt;Int&gt;)<br class="">}</div><div><br class=""></div><div>which gives:</div><div><span class="Apple-tab-span" style="white-space: pre;">        </span>let x = Int(randomInRange:&nbsp;0..&lt;5)</div><div><br class=""></div><div>The point of this is that you’re producing an Int (or whatever type). &nbsp;Regardless of whether the initializer is failable or not, this is the preferred way of creating a new value with some property: it is an initializer with a label.</div><div><br class=""></div><div>-Chris</div><div><br class=""></div><br class=""></body></html>