Method: Array#delete_if
- Defined in:
- array.c
#delete_if {|element| ... } ⇒ self #delete_if ⇒ Object
With a block given, calls the block with each element of self
; removes the element if the block returns a truthy value; returns self
:
a = [:foo, 'bar', 2, 'bat']
a.delete_if {|element| element.to_s.start_with?('b') } # => [:foo, 2]
With no block given, returns a new Enumerator.
Related: see Methods for Deleting.
4428 4429 4430 4431 4432 4433 4434 4435 |
# File 'array.c', line 4428
static VALUE
rb_ary_delete_if(VALUE ary)
{
ary_verify(ary);
RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length);
ary_reject_bang(ary);
return ary;
}
|