Tweaks or Array#select

This commit is contained in:
BurdetteLamar 2024-09-16 07:21:21 -05:00 committed by Peter Zhu
parent 1e52dde82a
commit 4e17fa2906
Notes: git 2024-09-16 16:33:24 +00:00

20
array.c
View File

@ -3853,22 +3853,22 @@ rb_ary_values_at(int argc, VALUE *argv, VALUE ary)
/*
* call-seq:
* array.select {|element| ... } -> new_array
* array.select -> new_enumerator
* select {|element| ... } -> new_array
* select -> new_enumerator
* filter {|element| ... } -> new_array
* filter -> new_enumerator
*
* Calls the block, if given, with each element of +self+;
* returns a new +Array+ containing those elements of +self+
* With a block given, calls the block with each element of +self+;
* returns a new array containing those elements of +self+
* for which the block returns a truthy value:
*
* a = [:foo, 'bar', 2, :bam]
* a1 = a.select {|element| element.to_s.start_with?('b') }
* a1 # => ["bar", :bam]
* a.select {|element| element.to_s.start_with?('b') }
* # => ["bar", :bam]
*
* Returns a new Enumerator if no block given:
*
* a = [:foo, 'bar', 2, :bam]
* a.select # => #<Enumerator: [:foo, "bar", 2, :bam]:select>
* With no block given, returns a new Enumerator.
*
* Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
*/
static VALUE