From 9cbf2f5fff83d776aff6068aca4a640d5144d197 Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Tue, 22 Oct 2024 11:36:12 -0500 Subject: [DOC] Tweaks for Array#take_while (#11930) --- array.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/array.c b/array.c index daa35ad197..f116cdd3f1 100644 --- a/array.c +++ b/array.c @@ -7509,25 +7509,23 @@ rb_ary_take(VALUE obj, VALUE n) /* * call-seq: - * array.take_while {|element| ... } -> new_array - * array.take_while -> new_enumerator - * - * Returns a new +Array+ containing zero or more leading elements of +self+; - * does not modify +self+. + * take_while {|element| ... } -> new_array + * take_while -> new_enumerator * * With a block given, calls the block with each successive element of +self+; - * stops if the block returns +false+ or +nil+; - * returns a new +Array+ containing those elements for which the block returned a truthy value: + * stops iterating if the block returns +false+ or +nil+; + * returns a new array containing those elements for which the block returned a truthy value: * * a = [0, 1, 2, 3, 4, 5] * a.take_while {|element| element < 3 } # => [0, 1, 2] - * a.take_while {|element| true } # => [0, 1, 2, 3, 4, 5] - * a # => [0, 1, 2, 3, 4, 5] + * a.take_while {|element| true } # => [0, 1, 2, 3, 4, 5] + * a.take_while {|element| false } # => [] * - * With no block given, returns a new Enumerator: + * With no block given, returns a new Enumerator. * - * [0, 1].take_while # => # + * Does not modify +self+. * + * Related: see {Methods for Fetching}[rdoc-ref:Array@Methods+for+Fetching]. */ static VALUE -- cgit v1.2.3