What's the implication of collection.indices.randomElement()
for large collections? I am guessing “not good”, given the rest of your post, otherwise randomElement
could just be implemented using that. I'm still thinking about @beccadax's concern from the pitch thread about breaking reasonable code. I suppose it depends how often people end up using .randomElement()
vs .random(in:)
. Perhaps a targeted warning about using .randomElement()
with known large ranges would cover most cases.