I added the PR for the trailing list edge case here: https://github.com/apache/groovy/pull/2180
On Mon, Apr 7, 2025 at 7:12 AM Paul King <pa...@asert.com.au> wrote: > > Actually, there is another edge case with chop that I would also like > to modify since we are making a change anyway. > > Even once the original source of elements is exhausted, we continue > "chopping" for each asked for size but give an empty list in such > cases. > > assert ['a', 'b', 'c', 'd', 'e'].chop(1, 2, 3, 3, 3) == [['a'], ['b', > 'c'], ['d', 'e'], [], []] > > I don't know of anyone relying on this behavior. It is different from > equivalent functionality in other languages/libraries. > > I'd like to make the default behavior be to stop once input elements > stop, but have a boolean flag to keep the existing behavior. This > gives a more sensible result if we allowed the chop sizes to be a > (possibly infinite) iterator. > > I'll create a PR. If folks don't like changing the default, we can > keep the current behavior but still have the boolean to flip to the > other behavior. I just think the other behavior, while sometimes could > be useful, is the rarer desired output of the two. Reminder, we are > just talking about the empty lists at the end of the above example. > > Cheers, Paul. > > > On Sat, Apr 5, 2025 at 11:28 PM OCsite <o...@ocs.cz> wrote: > > > > Hi there, > > > > On 4. 4. 2025, at 23:09, Mattias Reichel <mattias.reic...@gmail.com> wrote: > > I don't see a problem making a breaking change in a major version update. > > > > > > Well it's always somewhat at the inconvenient side for us who maintain a > > big codebase. > > > > On the other hand, when it's easy to find and fix all the places where the > > change did happen (like in this case), it's not that bad. Nevertheless > > changes which can't be easily found in sources (like e.g., the “foo?[]:... > > ” of late), can be a real PITA. > > > > All the best, > > OC > >