Tweaks or Array#select
This commit is contained in:
parent
1e52dde82a
commit
4e17fa2906
Notes:
git
2024-09-16 16:33:24 +00:00
20
array.c
20
array.c
@ -3853,22 +3853,22 @@ rb_ary_values_at(int argc, VALUE *argv, VALUE ary)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* array.select {|element| ... } -> new_array
|
* select {|element| ... } -> new_array
|
||||||
* array.select -> new_enumerator
|
* select -> new_enumerator
|
||||||
|
* filter {|element| ... } -> new_array
|
||||||
|
* filter -> new_enumerator
|
||||||
*
|
*
|
||||||
* Calls the block, if given, with each element of +self+;
|
* With a block given, calls the block with each element of +self+;
|
||||||
* returns a new +Array+ containing those elements of +self+
|
* returns a new array containing those elements of +self+
|
||||||
* for which the block returns a truthy value:
|
* for which the block returns a truthy value:
|
||||||
*
|
*
|
||||||
* a = [:foo, 'bar', 2, :bam]
|
* a = [:foo, 'bar', 2, :bam]
|
||||||
* a1 = a.select {|element| element.to_s.start_with?('b') }
|
* a.select {|element| element.to_s.start_with?('b') }
|
||||||
* a1 # => ["bar", :bam]
|
* # => ["bar", :bam]
|
||||||
*
|
*
|
||||||
* Returns a new Enumerator if no block given:
|
* With no block given, returns a new Enumerator.
|
||||||
*
|
|
||||||
* a = [:foo, 'bar', 2, :bam]
|
|
||||||
* a.select # => #<Enumerator: [:foo, "bar", 2, :bam]:select>
|
|
||||||
*
|
*
|
||||||
|
* Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user