mirror of
https://github.com/golang/go.git
synced 2025-05-05 15:43:04 +00:00
Revert e5998399c87e9f2de47e5108df584283db3c7fbd...46fe561befe97672f770640f831a9a545c77e540 on SliceTricks
parent
46fe561bef
commit
93fa5681d0
@ -177,7 +177,7 @@ Useful if you want to do batch processing on large slices.
|
||||
```go
|
||||
actions := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||
batchSize := 3
|
||||
batches := make([][]int, 0, (len(actions) / batchSize + 1))
|
||||
batches := make([][]int, 0, (len(actions) + batchSize - 1) / batchSize)
|
||||
|
||||
for batchSize < len(actions) {
|
||||
actions, batches = actions[batchSize:], append(batches, actions[0:batchSize:batchSize])
|
||||
|
Loading…
x
Reference in New Issue
Block a user