From: Gavin Sinclair Date: 2004-12-09T09:51:13+09:00 Subject: Re: [ANN] Ruby/Extensions v0.6.0 On Thursday, December 9, 2004, 11:32:31 AM, Florian wrote: >> So any array that properly implements size and at should do the trick. > I'm thinking about something like this: (Made-up sample, does not make > much sense in isolation -- but it could also happen in real code.) > class Enumerable > def find_some(chance = 0.5) > find_all { rand < chance } > end > end > I think using the Array#rand extension would lead to trouble in this case: > [1, 2, 3].find_some > Because Enumerable#find_some expects to call Kernel#rand. OIC. Yes, when dabbling in these waters I tend to be explicit, so I would use Kernel.rand instead. > I'm not sure if it is necessary to rename it (Array#pick_rand seems to > be a common candidate), but a note in the documentation might be a good > thing. Yes. I'll put something in. Gavin