diff options
author | Burdette Lamar <[email protected]> | 2022-05-28 14:20:00 -0500 |
---|---|---|
committer | <[email protected]> | 2022-05-28 14:20:00 -0500 |
commit | 8038d5e40a079d60dfcf7cab1155528959760c28 () | |
tree | 9be77d906a11b8ace32799e81a5d0242672eb95c /enum.c | |
parent | 6e3295e554aff8e48ff0a5a7aad587dce6d5bb29 (diff) |
Revert flawed doc for slice_after, slice_when, and chunk_while (#5952)
Restores doc for the methods that were cited in https://bugs.ruby-lang.org/issues/18765.
Notes: Merged-By: BurdetteLamar <[email protected]>
-rw-r--r-- | enum.c | 162 |
1 files changed, 107 insertions, 55 deletions
@@ -4079,39 +4079,24 @@ sliceafter_i(RB_BLOCK_CALL_FUNC_ARGLIST(yielder, enumerator)) /* * call-seq: - * slice_after(pattern) -> enumerator - * slice_after {|array| ... } -> enumerator * - * With argument +pattern+, returns an enumerator that uses the pattern - * to partition elements into arrays ("slices"). - * An element ends the current slice if <tt>element === pattern</tt>: * - * a = %w[foo bar fop for baz fob fog bam foy] - * e = a.slice_after(/ba/) # => #<Enumerator: ...> - * e.each {|array| p array } * - * Output: * - * ["foo", "bar"] - * ["fop", "for", "baz"] - * ["fob", "fog", "bam"] - * ["foy"] * - * With a block, returns an enumerator that uses the block - * to partition elements into arrays. - * An element ends the current slice if its block return is a truthy value: - * - * e = (1..20).slice_after {|i| i % 4 == 2 } # => #<Enumerator: ...> - * e.each {|array| p array } - * - * Output: - * - * [1, 2] - * [3, 4, 5, 6] - * [7, 8, 9, 10] - * [11, 12, 13, 14] - * [15, 16, 17, 18] - * [19, 20] * * Other methods of the Enumerator class and Enumerable module, * such as +map+, etc., are also usable. @@ -4225,23 +4210,65 @@ slicewhen_i(RB_BLOCK_CALL_FUNC_ARGLIST(yielder, enumerator)) /* * call-seq: - * slice_when {|element, next_element| ... } -> enumerator * - * The returned enumerator uses the block - * to partition elements into arrays ("slices"); - * it calls the block with each element and its successor; - * begins a new slice if and only if the block returns a truthy value: * - * a = [0, 1, 2, 4, 5, 6, 8, 9] - * e = a.slice_when {|i, j| j != i + 1 } - * e.each {|array| p array } * - * Output: * - * [0, 1, 2] - * [4, 5, 6] - * [8, 9] * */ static VALUE enum_slice_when(VALUE enumerable) @@ -4262,27 +4289,52 @@ enum_slice_when(VALUE enumerable) /* * call-seq: - * chunk_while {|element, next_element| ... } -> enumerator * - * The returned Enumerator uses the block to partition elements - * into arrays ("chunks"); - * it calls the block with each element and its successor; - * begins a new chunk if and only if the block returns a truthy value: * - * Example: * - * a = [1, 2, 4, 9, 10, 11, 12, 15, 16, 19, 20, 21] - * e = a.chunk_while {|i, j| j == i + 1 } - * e.each {|array| p array } * - * Output: * - * [1, 2] - * [4] - * [9, 10, 11, 12] - * [15, 16] - * [19, 20, 21] * */ static VALUE enum_chunk_while(VALUE enumerable) |