Details
-
New Feature
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.8.6
-
None
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]
Attachments
Issue Links
- is related to
-
GROOVY-4865 Add a take method to Collections, Iterators, Arrays
- Closed