Ruby 1.9.1 - Array.new.choice missing?

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)?

Hi,

In message “Re: Ruby 1.9.1 - Array.new.choice missing?”
on Tue, 4 Nov 2008 00:16:22 +0900, Boris S.
[email protected] 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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs