Details
-
Type:
Improvement
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
grep currently works on collections, but it would be nice to have it work on Iterators
We could then do lazy things like:
// Set our initial value def a = 1 // Define an iterator around this value def iter = [ hasNext:{ true }, next:{ a++ } ] as Iterator // Define a new iterator that will just emit odd numbers def oddIter = iter.grep { it % 2 } // Check it's working assert [ 1, 3, 5 ] == oddIter.take( 3 ).collect()