Skip to content

Commit 0809ef5

Browse files
brittojosevalim
authored andcommitted
Improve Stream.interval/1 documentation (#5480)
By warning about its blocking behavior and suggesting the use of `Stream.iterate/2` for generating number sequences.
1 parent e9a8c63 commit 0809ef5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/elixir/lib/stream.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,10 @@ defmodule Stream do
423423
This operation will block the caller by the given interval
424424
every time a new item is streamed.
425425
426+
Do not use this function to generate a sequence of numbers.
427+
If blocking the caller process is not necessary, use
428+
`Stream.iterate(0, & &1 + 1)` instead.
429+
426430
## Examples
427431
428432
iex> Stream.interval(10) |> Enum.take(10)

0 commit comments

Comments
 (0)