Joe Van Dyk
12/22/2005 11:12:00 PM
On 12/22/05, Sam Kong <sam.s.kong@gmail.com> wrote:
> Hi, folks!
>
> What's the easiest(simplest) code to find a class/module that first
> defines a specific method?
$ ri partition
--------------------------------------------------- Enumerable#partition
enum.partition {| obj | block } => [ true_array, false_array ]
------------------------------------------------------------------------
Returns two arrays, the first containing the elements of _enum_ for
which the block evaluates to true, the second containing the rest.
(1..6).partition {|i| (i&1).zero?} #=> [[2, 4, 6], [1, 3, 5]]