It would be useful to be able to optionally alter the behaviour of Collection:split() by passing a 2nd argument to the method so that the chunks it returns are as evenly as possible.
Currently, the resulting chunks are first-heavy:
collect({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}):split(3):all()
-- { {1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10} }
The intended behaviour with true passed as the 2nd argument would even out the number of values in each chunk:
collect({1, 2, 3, 4, 5, 6, 7, 8, 9, 10}):split(3, true):all()
-- { {1, 2, 3, 4}, {5, 6, 7}, {8, 9, 10} }
It would be useful to be able to optionally alter the behaviour of
Collection:split()by passing a 2nd argument to the method so that the chunks it returns are as evenly as possible.Currently, the resulting chunks are first-heavy:
The intended behaviour with
truepassed as the 2nd argument would even out the number of values in each chunk: