Forum: Ruby Ruby 1.9.1 - Array.new.choice missing?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
409bbe5af67a049f87e019ac0275dbc1?d=identicon&s=25 Boris Schmid (bor_)
on 2008-11-03 16:17
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)?
0ec4920185b657a03edf01fff96b4e9b?d=identicon&s=25 Yukihiro Matsumoto (Guest)
on 2008-11-03 16:36
(Received via mailing list)
Hi,

In message "Re: Ruby 1.9.1 - Array.new.choice missing?"
    on Tue, 4 Nov 2008 00:16:22 +0900, Boris Schmid
<borisschmid@gmail.com> 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 topic is locked and can not be replied to.