<div dir="ltr">> On 7 Oct 2017, at 04:24, Chris Lattner via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
><br>
>> These aren’t the forms I was suggesting, what I meant was:<br>
><br>
> extension Int {<br>
> init(randomInRange: Countable{Closed}Range<Int>)<br>
> }<br>
><br>
> which gives:<br>
> let x = Int(randomInRange: 0..<5)<br>
><br>
> The point of this is that you’re producing an Int (or whatever type). 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.<br></blockquote><div><br></div><div>every now and then i found myself in a situation i want to use this preferred way, and i need a label... but i do not have anything to pass, e.g.:</div><div><br></div><div>let x = Int(random) // oops<br></div><div><br></div><div>has to resort to hacks: let x = Int(random: ())</div><div>or make it a non-initialiser: let x = Int.random or Int.random()</div><div><br></div><div>have you guys considered: func random<T>(...) -> T</div><div>where it returns a different type based on a context?</div><div><br></div><div>Mike</div><div><br></div></div></div></div>