From: Yossef Mendelssohn Date: 2008-02-27T01:13:32+09:00 Subject: Re: # arguments to rand On Feb 26, 8:52 am, Calamitas wrote: > On 26/02/2008, d c wrote: > > > hi - > > > can someone help with suggesting what is wrong below? i am trying to > > add a simple method to array#random > > > but get the wrong number of args error... > > have tried lots of variations! > > > >> class Array > > >> def random > > >> n = rand(self.size.to_i) > > You are probably calling Array#rand as defined by Rails. If so, it > does what your Array#random is supposed to do and you can use it > directly. Otherwise you can call Kernel.rand instead of just rand. > > Peter This is what I was going to bring up. I'd also like to add that it was a wonderful decision on Norbert Crombach's part to name the method Array#rand rather than Array#random so that confusion and/or annoyance would set in were one to attempt to add another method to Array that attempts to use random numbers. Oh, also the Rails core team in general for not bringing this up and accepting the patch without a comment. -- -yossef