<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 30, 2017, at 5:02 PM, Jonathan Hull &lt;<a href="mailto:jhull@gbis.com" class="">jhull@gbis.com</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; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Nov 30, 2017, at 3:52 PM, Dave DeLong &lt;<a href="mailto:swift@davedelong.com" class="">swift@davedelong.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">What is the useful distinction between generating a random value, and choosing a random element from a collection of all possible values?</span></div></blockquote></div><br class=""><div class="">I don’t have to generate (or keep in memory) that collection. &nbsp;</div><div class=""><br class=""></div><div class="">I gave an example before of an easy to add API for random colors which allow their saturation, lightness, and alpha to be fixed. &nbsp;I use something very similar all the time in some graphics code I have (varying only the hue or saturation). &nbsp;I also do the same with Sizes and CGVectors. &nbsp;How would you represent that as a collection to choose an element from?</div></div></div></blockquote><div><br class=""></div><div>You’re not picking a random color. You’re picking a random hue or a random saturation, and then constructing a color based off that. In other words, you’re choosing a value from 0…1:</div><div><br class=""></div><div>let color = UIColor(hue: (0…1.0).random(), saturation: knownSaturationValue, brightness: knownBrightnessValue, alpha: knownAlphaValue)</div><div><br class=""></div><div>Dave</div><br class=""><blockquote type="cite" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Also, for most of my use cases, I *need* to be able to plug in a repeatably random source… otherwise pixels will start jumping around the screen when people resize things.</div></div></blockquote><div><br class=""></div><div>That’s cool; I’m totally in favor of the RandomSource API as a way to model different distributions or algorithms or whatever. I just don’t thing “Foo.random” is a good idea.</div><div><br class=""></div><div>Cheers</div><div><br class=""></div><div>Dave</div></div></body></html>