Ruby Newbie homepage Ruby Newbie homepage

How to use

Quick guide

Official content
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.
Returns a new Enumerator if no block given:
a = [:foo, 'bar', 2]
a.reject! # => #<Enumerator: [:foo, "bar", 2]:reject!>
               static VALUE
rb_ary_reject_bang(VALUE ary)
    RETURN_SIZED_ENUMERATOR(ary, 0, 0, ary_enum_length);
    return ary_reject_bang(ary);

Was this page useful?