Bug #18765
closedWrong description introduced by https://github.com/ruby/ruby/pull/4938/files
Description
Commit https://github.com/ruby/ruby/pull/4938/files introduced problems and made the description wrong.
-
For methods
slice_after
andslice_when
, it introduces expressions like "partition elements into arrays ('slices')", and for methodchunk_while
, "partition elements into arrays ('chunks')". It suggests to call the resulting elements using different words depending on the name of the method. But that does not make sense. They are all simply arrays, and there is no need to distinguish a "slice array" from a "chunk array". (They can all be called an "array", "slice", or "chunk", or whatever.)Perhaps, it is attempting to explain where the method names came from, under the assumption that the words "slice" and "chunk" in these method names are nouns. If so, that is wrong. The succeeding parts "when (block)" and "while (block)" are (to correspond to English) adverbial clauses, not adjectival (relative) clauses; hence, these "slice" and "chunk" must be interpreted as verbs, not nouns. In fact, "a slice when y is not a successor of x" or "a chunk while y is a successor of x" does not make sense, whereas "slice it when y is not a successor of x" and "chunk them while y is a successor of x" do make sense.
The difference between the "slice" and "chunk" methods lies in the process, not the return value. If you want to use these words, it can be something like "slice the receiver into arrays when the block returns a truthy value" and "chunk the elements together while the block returns a truthy value".
-
In the description of
slice_when
andchunk_while
, it says "it calls the block with each element and its successor", but that is not true. If you are going to phrase it that way, then it only calls each element except for the last one. -
In the description of
slice_when
, it says "begins a new slice if and only if the block returns a truthy value", but that is not true. Regardless of the value of the block, the first element always begins a new "slice". -
Most crucially, in the description of
chunk_while
, the expression "begins a new chunk if and only if the block returns a truthy value" is entirely wrong.
Updated by hsbt (Hiroshi SHIBATA) over 2 years ago
- Status changed from Open to Assigned
- Assignee set to burdettelamar@yahoo.com (Burdette Lamar)
Updated by jeremyevans0 (Jeremy Evans) over 2 years ago
- Status changed from Assigned to Closed
Updated by nagachika (Tomoyuki Chikanaga) over 2 years ago
- Backport changed from 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN to 2.7: DONTNEED, 3.0: DONTNEED, 3.1: REQUIRED
Updated by nagachika (Tomoyuki Chikanaga) over 1 year ago
- Backport changed from 2.7: DONTNEED, 3.0: DONTNEED, 3.1: REQUIRED to 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONE
ruby_3_1 9f072e9ae1bae2d76334c9e97a47280779768859 merged revision(s) 8038d5e40a079d60dfcf7cab1155528959760c28.