Skip to content

Commit 59a99f9

Browse files
committed
Clarify Enum.chunk/4 behavior with partial chunks
1 parent fa920eb commit 59a99f9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/elixir/lib/enum.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ defmodule Enum do
335335
elements are taken as necessary from `leftover` if it was passed.
336336
337337
If `leftover` is passed and does not have enough elements to fill the
338-
chunk, then the chunk is returned anyway with less than `count`
338+
chunk, then a partial chunk is returned with less than `count`
339339
elements. If `leftover` is not passed at all or is `nil`, then the
340340
partial chunk is discarded from the result.
341341
@@ -350,8 +350,8 @@ defmodule Enum do
350350
iex> Enum.chunk([1, 2, 3, 4, 5, 6], 3, 2, [7])
351351
[[1, 2, 3], [3, 4, 5], [5, 6, 7]]
352352
353-
iex> Enum.chunk([1, 2, 3, 4, 5, 6], 3, 3, [])
354-
[[1, 2, 3], [4, 5, 6]]
353+
iex> Enum.chunk([1, 2, 3, 4], 3, 3, [])
354+
[[1, 2, 3], [4]]
355355
356356
"""
357357
@spec chunk(t, pos_integer, pos_integer, t | nil) :: [list]

0 commit comments

Comments
 (0)