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 2019/08/16 23:16:00 UTC

[jira] [Updated] (GROOVY-5414) Groovy could benefit from DGM takeWhile and dropWhile methods

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

Paul King updated GROOVY-5414:
------------------------------
    Issue Type: New Feature  (was: Improvement)

> Groovy could benefit from DGM takeWhile and dropWhile methods
> -------------------------------------------------------------
>
>                 Key: GROOVY-5414
>                 URL: https://issues.apache.org/jira/browse/GROOVY-5414
>             Project: Groovy
>          Issue Type: New Feature
>          Components: groovy-jdk
>    Affects Versions: 1.8.6
>            Reporter: Andrew Taylor
>            Assignee: Paul King
>            Priority: Minor
>             Fix For: 2.0-beta-3, 1.8.7
>
>
> Currently, there is a take method on collections that returns the first N items in a collection.  Other languages such as scala and haskell also provide a takeWhile method, that is similar.  Instead of taking a fixed number of items, it takes items until a condition, in the form of a closure, is met.
> For example:
> {code}
> def items = [1,2,3,4,5,4,3,2,1]
> def sublist = items.takeWhile { it < 5 }
> assert sublist == [1,2,3,4]
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.14#76016)