Shouldn't it be

    random.choose(from: 1...6)

etc.?

-Thorsten 

> Am 28.11.2017 um 00:20 schrieb Martin Waitz via swift-evolution 
> <swift-evolution@swift.org>:
> 
> Hello,
> 
>> 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.
> 
> -- 
> Martin
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to