Method: Enumerable#reject
- Defined in:
- enum.c
#reject {|obj| ... } ⇒ Array #reject ⇒ Object
Returns an array for all elements of enum for which the given block returns false.
If no block is given, an Enumerator is returned instead.
(1..10).reject { |i| i % 3 == 0 } #=> [1, 2, 4, 5, 7, 8, 10]
[1, 2, 3, 4, 5].reject { |num| num.even? } #=> [1, 3, 5]
See also Enumerable#find_all.
559 560 561 562 563 564 565 566 567 568 569 570 |
# File 'enum.c', line 559
static VALUE
enum_reject(VALUE obj)
{
VALUE ary;
RETURN_SIZED_ENUMERATOR(obj, 0, 0, enum_size);
ary = rb_ary_new();
rb_block_call(obj, id_each, 0, 0, reject_i, ary);
return ary;
}
|