@@ -154,7 +154,7 @@ pub fn group[T](arrs ...[]T) [][]T {
154154}
155155
156156// chunk array into a single array of arrays where each element is the next `size` elements of the original.
157- // Example: arrays.chunk([1, 2, 3, 4, 5, 6, 7, 8, 9], 2)) // => [[1, 2], [3, 4], [5, 6], [7, 8], [9]]
157+ // Example: arrays.chunk([1, 2, 3, 4, 5, 6, 7, 8, 9], 2) // => [[1, 2], [3, 4], [5, 6], [7, 8], [9]]
158158pub fn chunk [T](array []T, size int ) [][]T {
159159 // allocate chunk array
160160 mut chunks := [][]T{cap: array.len / size + if array.len % size == 0 { 0 } else { 1 }}
@@ -425,11 +425,10 @@ pub fn group_by[K, V](array []V, grouping_op fn (val V) K) map[K][]V {
425425}
426426
427427// concatenate an array with an arbitrary number of additional values.
428- //
429- // NOTE: if you have two arrays, you should simply use the `<<` operator directly
430- // Example: arrays.concat([1, 2, 3], 4, 5, 6) == [1, 2, 3, 4, 5, 6] // => true
431- // Example: arrays.concat([1, 2, 3], ...[4, 5, 6]) == [1, 2, 3, 4, 5, 6] // => true
432- // Example: arr << [4, 5, 6] // does what you need if arr is mutable
428+ // NOTE: if you have two arrays, you should simply use the `<<` operator directly.
429+ // Example: assert arrays.concat([1, 2, 3], 4, 5, 6) == [1, 2, 3, 4, 5, 6]
430+ // Example: assert arrays.concat([1, 2, 3], ...[4, 5, 6]) == [1, 2, 3, 4, 5, 6]
431+ // Example: mut arr := arrays.concat([1, 2, 3], 4); arr << [10,20]; assert arr == [1,2,3,4,10,20] // note: arr is mutable
433432pub fn concat [T](a []T, b ...T) []T {
434433 mut m := []T{cap: a.len + b.len}
435434
0 commit comments