[swift-evolution] [Proposal] Random Unification
tseitz42 at icloud.com
Wed Nov 29 00:10:08 CST 2017
Shouldn't it be
> Am 28.11.2017 um 00:20 schrieb Martin Waitz via swift-evolution <swift-evolution at swift.org>:
>> Maybe we call the default RNG instance `random`, and then give the `random(in:)` methods another name, like `choose(in:)`?
>> let diceRoll = random.choose(in: 1...6)
>> let card = random.choose(in: deck)
>> let isHeads = random.choose(in: [true, false])
>> let probability = random.choose(in: 0.0...1.0)
>> let diceRoll = rng.choose(in: 1...6)
>> let card = rng.choose(in: deck)
>> let isHeads = rng.choose(in: [true, false])
>> let probability = rng.choose(in: 0.0...1.0)
> 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.
> Modeling that as methods of the RNG seems to be much more natural.
> swift-evolution mailing list
> swift-evolution at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution