Skip to content

Commit be012a1

Browse files
committed
update array
1 parent 0d500fd commit be012a1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

helpers/chumk.go arrays/chunk.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
package helpers
1+
package arrays
22

33
// Chunk will take a slice of any kind and a chunk size and return a slice of slices
44
func Chunk[T any](arr []T, chunkSize int) [][]T {
5-
var chunks [][]T
5+
chunks := [][]T{}
66
for i := 0; i < len(arr); i += chunkSize {
77
end := i + chunkSize
88
if end > len(arr) {
99
end = len(arr)
1010
}
1111
chunks = append(chunks, arr[i:end])
1212
}
13+
1314
return chunks
1415
}

0 commit comments

Comments
 (0)