Project

General

Profile

Bug #18765

Updated by sawa (Tsuyoshi Sawada) almost 2 years ago

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, 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. 

Back