public Method

Enumerable.select

enum.find_all {| obj | block }   array
enum.select   {| obj | block }   array

Returns an array containing all elements of enum for which block is not false (see also Enumerable#reject).

(1..10).find_all {|i|  i % 3 == 0 }   #=> [3, 6, 9]

Source Code

/*
*  call-seq:
*     enum.find_all {| obj | block }  => array
*     enum.select   {| obj | block }  => array
*  
*  Returns an array containing all elements of <i>enum</i> for which
*  <em>block</em> is not <code>false</code> (see also
*  <code>Enumerable#reject</code>).
*     
*     (1..10).find_all {|i|  i % 3 == 0 }   #=> [3, 6, 9]
*     
*/

static VALUE
enum_find_all(obj)
   VALUE obj;
{
   VALUE ary = rb_ary_new();

   rb_iterate(rb_each, obj, find_all_i, ary);

   return ary;
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.