2 ms·
> I don't see the confusion. #1 would be .random(), #2 would be .random(Int), and #3 would be .shuffle() with both mutating and non-mutating versions. All thre
by masklinn 11y ago
> I don't see the confusion. #1 would be .random(), #2 would be .random(Int), and #3 would be .shuffle() with both mutating and non-mutating versions.
All three operations are random, naming something "random" provides no indication whether it's a random indexing or a random shuffling.
> There could be all three of these methods, which you could use depending on your needs.
Sure, but there isn't, and the one operation which is provided is the one you can't use as basic building blocks for the other two.
> The purpose of a standard library is to make common things easy. At least one of these three functions are found in nearly all other languages' standard libraries I've ever used.
Your point being? I'm not saying the operation is useless, I'm saying the naming is confusing and out of 3 possible operations using that name, the least useful one was selected.