Skip to content

Commit 9cbf2f5

Browse files
[DOC] Tweaks for Array#take_while (ruby#11930)
1 parent c837ae8 commit 9cbf2f5

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

array.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7509,25 +7509,23 @@ rb_ary_take(VALUE obj, VALUE n)
75097509

75107510
/*
75117511
* call-seq:
7512-
* array.take_while {|element| ... } -> new_array
7513-
* array.take_while -> new_enumerator
7514-
*
7515-
* Returns a new +Array+ containing zero or more leading elements of +self+;
7516-
* does not modify +self+.
7512+
* take_while {|element| ... } -> new_array
7513+
* take_while -> new_enumerator
75177514
*
75187515
* With a block given, calls the block with each successive element of +self+;
7519-
* stops if the block returns +false+ or +nil+;
7520-
* returns a new +Array+ containing those elements for which the block returned a truthy value:
7516+
* stops iterating if the block returns +false+ or +nil+;
7517+
* returns a new array containing those elements for which the block returned a truthy value:
75217518
*
75227519
* a = [0, 1, 2, 3, 4, 5]
75237520
* a.take_while {|element| element < 3 } # => [0, 1, 2]
7524-
* a.take_while {|element| true } # => [0, 1, 2, 3, 4, 5]
7525-
* a # => [0, 1, 2, 3, 4, 5]
7521+
* a.take_while {|element| true } # => [0, 1, 2, 3, 4, 5]
7522+
* a.take_while {|element| false } # => []
75267523
*
7527-
* With no block given, returns a new Enumerator:
7524+
* With no block given, returns a new Enumerator.
75287525
*
7529-
* [0, 1].take_while # => #<Enumerator: [0, 1]:take_while>
7526+
* Does not modify +self+.
75307527
*
7528+
* Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching].
75317529
*/
75327530

75337531
static VALUE

0 commit comments

Comments
 (0)