Issue #18765 has been updated by nagachika (Tomoyuki Chikanaga).
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.
----------------------------------------
Bug #18765: Wrong description introduced by
https://github.com/ruby/ruby/pull/4938/files
https://bugs.ruby-lang.org/issues/18765#change-101996
* Author: sawa (Tsuyoshi Sawada)
* Status: Closed
* Priority: Normal
* Assignee: burdettelamar(a)yahoo.com (Burdette Lamar)
* ruby -v: 3.1.0
* Backport: 2.7: DONTNEED, 3.0: DONTNEED, 3.1: DONE
----------------------------------------
Commit
https://github.com/ruby/ruby/pull/4938/files introduced problems and made the
description wrong.
1) For methods `slice_after` and `slice_when`, it introduces expressions like
"partition elements into arrays ('slices')", and for method
`chunk_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".
2) In the description of `slice_when` and `chunk_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.
3) 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".
4) 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.
--
https://bugs.ruby-lang.org/