Skip to content

Commit 14c0551

Browse files
committed
update documentation for select and reject
1 parent 5571c73 commit 14c0551

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

array.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2408,13 +2408,13 @@ rb_ary_values_at(int argc, VALUE *argv, VALUE ary)
24082408
* ary.select { |item| block } -> new_ary
24092409
* ary.select -> Enumerator
24102410
*
2411-
* Invokes the given block passing in successive elements from +self+,
2412-
* returning an array containing those elements for which the block returns
2413-
* a +true+ value.
2411+
* Returns a new array containing all elements of <i>ary</i>
2412+
* for which <em>block</em> does not return <code>false</code>
2413+
* (see also <code>Enumerable#select</code>).
24142414
*
2415-
* See also Enumerable#select.
2415+
* If no block is given, an enumerator is returned instead.
24162416
*
2417-
* If no block is given, an Enumerator is returned instead.
2417+
* [1,2,3,4,5].select { |num| num.even? } #=> [2, 4]
24182418
*
24192419
* a = %w{ a b c d e f }
24202420
* a.select { |v| v =~ /[aeiou]/ } #=> ["a", "e"]

enum.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,17 @@ find_all_i(VALUE i, VALUE ary, int argc, VALUE *argv)
311311
* enum.find_all -> an_enumerator
312312
* enum.select -> an_enumerator
313313
*
314-
* Returns an array containing all elements of <i>enum</i> for which
315-
* <em>block</em> is not <code>false</code> (see also
316-
* <code>Enumerable#reject</code>).
314+
* Returns an array containing all elements of <i>enum</i>
315+
* for which <em>block</em> does not return <code>false</code>
316+
* (see also <code>Enumerable#reject</code>).
317317
*
318318
* If no block is given, an enumerator is returned instead.
319319
*
320320
*
321321
* (1..10).find_all { |i| i % 3 == 0 } #=> [3, 6, 9]
322322
*
323+
* [1,2,3,4,5].select { |num| num.even? } #=> [2, 4]
324+
*
323325
*/
324326

325327
static VALUE
@@ -352,12 +354,14 @@ reject_i(VALUE i, VALUE ary, int argc, VALUE *argv)
352354
* enum.reject -> an_enumerator
353355
*
354356
* Returns an array for all elements of <i>enum</i> for which
355-
* <em>block</em> is false (see also <code>Enumerable#find_all</code>).
357+
* <em>block</em> returns false (see also <code>Enumerable#find_all</code>).
356358
*
357359
* If no block is given, an enumerator is returned instead.
358360
*
359361
* (1..10).reject { |i| i % 3 == 0 } #=> [1, 2, 4, 5, 7, 8, 10]
360362
*
363+
* [1, 2, 3, 4, 5].reject { |num| num.even? } #=> [1, 3, 5]
364+
*
361365
*/
362366

363367
static VALUE

0 commit comments

Comments
 (0)