From: Logan Capaldo Date: 2007-08-16T11:25:23+09:00 Subject: Re: How do you choose a random word from an array? ------=_Part_49261_17397789.1187231125703 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 8/15/07, Ilan Berci wrote: > > Stefano Crocco wrote: > > > > > christmas_bin[rand(christmas_bin.size)] > > > Now to combine what Stefano did with your earlier request: > irb(main):001:0> class Array > irb(main):002:1> def rand; self[Kernel.rand(self.size)]; end > irb(main):003:1> end > => nil > irb(main):004:0> [1,2,3].rand > => 3 I like to write it like this: class Array def rand at(super(size)) end end -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_49261_17397789.1187231125703--