In article <404A1364.5020105 / hypermetrics.com>,
Hal Fulton  <hal9000 / hypermetrics.com> wrote:
>Charles Comstock wrote:
>> Why doesn't rand take an integer range and then generate a random number 
>> in between the two?
>> 
>> Example:
>>     rand(5..10) -> a random number from 5 to 10 including 10
>>     rand(5...10) -> a random number from 5 to 10 excluding 10
>> 
>> That or maybe add rand to range so it picks a random item out of the 
>> range.  For that matter why doesn't Array/Hash have a method to return a 
>> random element?
>> That way [1,2,4].rand and (5..10).rand would work.
>
>Charles,
>
>We were talking about this in IRC. Maybe you were one of those? :)
>
>Someone suggested allowing not just rand(Fixnum) and rand(Range)
>but in general rand(Enumerable).
>
>Someone else said: That's kind of "overloading" the meaning of rand.
>Well, I can see that might not be appropriate.
>
>I think if it were my decision, I'd do something like:
>
>1. Let rand accept a (numeric) Range, since rand is already a numeric
>    kind of thing.
>2. Add pick to Enumerable to pick a random element. (See #3)
>3. Add pick! also, to do a pick with deletion. (rand! is not an
>    intuitive name)

I like this a lot.  Please submit an RCR.

Phil