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.
525 526 527 528 529 530 531 532 533 534 535 536 |
# File 'enum.c', line 525 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; } |