You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2018/08/14 08:06:02 UTC

[jira] [Closed] (GROOVY-8733) Groovy could provide a chop DGM method

     [ https://issues.apache.org/jira/browse/GROOVY-8733?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-8733.
-----------------------------

> Groovy could provide a chop DGM method
> --------------------------------------
>
>                 Key: GROOVY-8733
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8733
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 2.5.2
>
>
> The method would chop the list into pieces at a specified chop size (or chop sizes).
> {code}
> assert [1, 2, 3, 4].chop(1) == [[1]]
> assert [1, 2, 3, 4].chop(1,-1) == [[1], [2, 3, 4]]
> assert ('a'..'h').chop(2, 4) == [['a', 'b'], ['c', 'd', 'e', 'f']]
> assert ['a', 'b', 'c', 'd', 'e'].chop(3) == [['a', 'b', 'c']]
> assert ['a', 'b', 'c', 'd', 'e'].chop(1, 2, 3) == [['a'], ['b', 'c'], ['d', 'e']]
> assert ['a', 'b', 'c', 'd', 'e'].chop(1, 2, 3, 3, 3) == [['a'], ['b', 'c'], ['d', 'e'], [], []]
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)