[swift-evolution] [Proposal] Random Unification

Martin Waitz tali at admingilde.org
Thu Nov 30 10:29:42 CST 2017


Hi Erica,

> Doesn't `choose` usually take two arguments, the `count` to choose (presumably defaulting to 1) and the collection to choose `from`?

This might be useful for collections, when you want to draw several elements without drawing the same element twice.
For ranges of random numbers you usually need independent numbers and just call the generator multiple times.
Both use cases could be provided as overloads (a default argument would require that the return value has the same type, which would be unfortunate here).

-- 
Martin


More information about the swift-evolution mailing list