Ruby 1.9.1 - Array.new.choice missing?


#1

Just wondering if I missed something. Ruby 1.9.1 doesn’t seem to have
.choice anymore as a way to select a random element from an array. Has
this been replaced by another functionname, or should I just use
rand(Array.size)?


#2

Hi,

In message “Re: Ruby 1.9.1 - Array.new.choice missing?”
on Tue, 4 Nov 2008 00:16:22 +0900, Boris S.
removed_email_address@domain.invalid writes:

|Just wondering if I missed something. Ruby 1.9.1 doesn’t seem to have
|.choice anymore as a way to select a random element from an array. Has
|this been replaced by another functionname, or should I just use
|rand(Array.size)?

It’s renamed to #sample.

          matz.