<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 4 Mar 2017, at 06:58, Charlie Monroe 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=""><div class="">While I am not against the idea, I believe that this is not as easy as one would think as everyone has a different understanding of the word "random" as most of random generators aren't "true" random generators.<br class=""><br class="">I think this would ideally require a new protocol RandomGenerator which would be passed to the collection to get the random element, i.e. it would look something like:<br class=""><br class="">arr.randomElement(using: ARC4RandomGenerator())<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Mar 4, 2017, at 6:55 AM, Jonathan Hull via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class="">This is a small improvement, but I still think it is worthwhile.<br class=""><br class="">I would like to see an 'init(randomIn: Range&lt;Self&gt;)’ added to Numeric (where Comparable), which would return a random number in the given range. &nbsp;It is something I have added myself to a subset of number types, but it really should be part of the standard library since there are a million small number types that have to be added individually, there are a couple of tricky edge cases to get right, and my version won’t work with Numeric types added by others.<br class=""><br class="">I would also like to see a ‘randomElement’ method added to collection. &nbsp;This is much easier to get right ourselves, but it comes up often enough in generic code that I still think it is a worthwhile addition…<br class=""></blockquote></div></div></blockquote></div><div class=""><br class=""></div><div class="">I suppose the question is whether a default PRNG on numeric types is "good enough", since most developers just need <i class="">some</i> randomness, it doesn't matter how good it actually is. Anyone with stricter requirements shouldn't be using a black-box, default generator.</div><div class=""><br class=""></div><div class="">That said, my preference is to just keep a stable of useful generators and allow developers to choose their preference; if they want they can easily add a constructor via extension, or a factory method or whatever, in which case they have control over the default.</div></body></html>