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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

JIRA jira@apache.org

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

Paul King resolved GROOVY-8733.
-------------------------------
       Resolution: Fixed
         Assignee: Paul King
    Fix Version/s: 2.5.2

Added as per description.

> 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)