Skip to content

Commit deb4a6b

Browse files
well-in-that-caseSainan
authored andcommitted
Document table.chunk
1 parent 0f0e683 commit deb4a6b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/Runtime Environment/Table.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,4 +272,23 @@ local t = {
272272
}
273273
274274
print(t:countvalues()) --> { [1] = 1, [2] = 2, [3] = 3, [4] = 4, ["value"] = 2 }
275+
```
276+
---
277+
### `table.chunk`
278+
Generates a new table which collects the values of the input and represents them in chunks of a specified size.
279+
#### Parameters
280+
1. The table.
281+
2. The desired `size` of each chunk.
282+
#### Errors
283+
An error is thrown if `size` is not greater than zero.
284+
```pluto
285+
local t = {
286+
1,
287+
2,
288+
3,
289+
["key"] = "hello",
290+
["other key"] = "world"
291+
}
292+
293+
print(t:chunk(3)) --> { { 1, 2, 3 }, { "hello", "world" } }
275294
```

0 commit comments

Comments
 (0)