Reputation: 8231
I wonder there might be a built-in feature in Groovy, something like
aCollection.doEachBulk(100) { bulk -> ... }
Is there ?
Upvotes: 1
Views: 100
Reputation: 19219
I'm not sure if I understand your question correctly, but you may be looking for the collate method.
collate
(1..20).collate(5).each { subRange -> println subRange }
Output:
[1, 2, 3, 4, 5] [6, 7, 8, 9, 10] [11, 12, 13, 14, 15] [16, 17, 18, 19, 20]
Upvotes: 4