Method: Array#reject!
- Defined in:
- array.c
#reject! {|element| ... } ⇒ self? #reject! ⇒ Object
With a block given, calls the block with each element of self; removes each element for which the block returns a truthy value.
Returns self if any elements removed:
a = [:foo, 'bar', 2, 'bat']
a.reject! {|element| element.to_s.start_with?('b') } # => [:foo, 2]
Returns nil if no elements removed.
With no block given, returns a new Enumerator.
Related: see Methods for Deleting.
4375 4376 4377 4378 4379 4380 4381 |
# File 'array.c', line 4375
static VALUE
rb_ary_reject_bang(VALUE ary)
{
RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length);
rb_ary_modify(ary);
return ary_reject_bang(ary);
}
|