Subject: Re: Is it more convenient to have a random_each in ruby stdlib?
From: transfire gmail.com
Date: Mon, 19 Jun 2006 19:29:52 +0900
References: 197996198000198003
In-reply-to: 198003
transfire / gmail.com wrote:
> Perhaps...
>
> class Array
> def random_each
> ((0...size).to_a.sort_by{rand}).each { |i|
> yield self[i]
> }
> end
> end
On second though, that still sorts an array of the same size. Hmm...
T.