Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: 1.8.6
-
Fix Version/s: 2.0-beta-3, 1.8.7
-
Component/s: groovy-jdk
-
Labels:None
-
Testcase included:yes
-
Number of attachments :
Description
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:
def items = [1,2,3,4,5,4,3,2,1]
def sublist = items.takeWhile { it < 5 }
assert sublist == [1,2,3,4]
Issue Links
- is related to
-
GROOVY-4865
Add a take method to Collections, Iterators, Arrays
-
Activity
Paul King
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Link |
This issue is related to |
Paul King
made changes -
| Summary | Collections could benefit from a takeWhile method | Groovy could benefit from DGM takeWhile and dropWhile methods |
| Assignee | Paul King [ paulk ] |
Paul King
made changes -
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Fix Version/s | 2.0-beta-3 [ 18244 ] | |
| Fix Version/s | 1.8.7 [ 18317 ] | |
| Resolution | Fixed [ 1 ] |
Paul King
made changes -
| Status | Resolved [ 5 ] | Closed [ 6 ] |