Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道 Groovy 中可能有一个内置功能,比如
aCollection.doEachBulk(100) { bulk -> ... }
有没有 ?
我不确定我是否正确理解了您的问题,但您可能正在寻找collate方法。
collate
(1..20).collate(5).each { subRange -> println subRange }
输出:
[1, 2, 3, 4, 5] [6, 7, 8, 9, 10] [11, 12, 13, 14, 15] [16, 17, 18, 19, 20]