Skip to content

Commit

Permalink
[DOC] Tweaks for Array#keep_if
Browse files Browse the repository at this point in the history
  • Loading branch information
BurdetteLamar authored and peterzhu2118 committed Oct 1, 2024
1 parent e72e18b commit 5edc321
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -3971,20 +3971,18 @@ rb_ary_select_bang(VALUE ary)

/*
* call-seq:
* array.keep_if {|element| ... } -> self
* array.keep_if -> new_enumeration
* keep_if {|element| ... } -> self
* keep_if -> new_enumerator
*
* Retains those elements for which the block returns a truthy value;
* deletes all other elements; returns +self+:
* With a block given, calls the block with each element of +self+;
* removes the element from +self+ if the block does not return a truthy value:
*
* a = [:foo, 'bar', 2, :bam]
* a.keep_if {|element| element.to_s.start_with?('b') } # => ["bar", :bam]
*
* Returns a new Enumerator if no block given:
*
* a = [:foo, 'bar', 2, :bam]
* a.keep_if # => #<Enumerator: [:foo, "bar", 2, :bam]:keep_if>
* With no block given, returns a new Enumerator.
*
* Related: see {Methods for Deleting}[rdoc-ref:Array@Methods+for+Deleting].
*/

static VALUE
Expand Down

0 comments on commit 5edc321

Please sign in to comment.