<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>Shouldn't it be</div><div><br></div><div> random.choose(<b>from:</b> 1...6)</div><div><br></div><div>etc.?</div><div><br></div><div>-Thorsten </div><div><br>Am 28.11.2017 um 00:20 schrieb Martin Waitz via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>>:<br><br></div><blockquote type="cite"><div><span>Hello,</span><br><span></span><br><blockquote type="cite"><span>Maybe we call the default RNG instance `random`, and then give the `random(in:)` methods another name, like `choose(in:)`?</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span> let diceRoll = random.choose(in: 1...6)</span><br></blockquote><blockquote type="cite"><span> let card = random.choose(in: deck)</span><br></blockquote><blockquote type="cite"><span> let isHeads = random.choose(in: [true, false])</span><br></blockquote><blockquote type="cite"><span> let probability = random.choose(in: 0.0...1.0)</span><br></blockquote><blockquote type="cite"><span> </span><br></blockquote><blockquote type="cite"><span> let diceRoll = rng.choose(in: 1...6)</span><br></blockquote><blockquote type="cite"><span> let card = rng.choose(in: deck)</span><br></blockquote><blockquote type="cite"><span> let isHeads = rng.choose(in: [true, false])</span><br></blockquote><blockquote type="cite"><span> let probability = rng.choose(in: 0.0...1.0)</span><br></blockquote><span></span><br><span>I like this design a lot. After all, `random` is not a property of some type or instance, but we want to generate a new random element within some range/based on some given set.</span><br><span>Modeling that as methods of the RNG seems to be much more natural.</span><br><span></span><br><span>-- </span><br><span>Martin</span><br><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>