IO.stream

You're seeing just the function stream, go back to IO module for more information.

Returns a line-based IO.Stream on :stdio.

This is equivalent to:

IO.stream(:stdio, :line)
Link to this function

stream(device \\ :stdio, line_or_codepoints)

View Source

Specs

stream(device(), :line | pos_integer()) :: Enumerable.t()

Converts the IO device into an IO.Stream.

An IO.Stream implements both Enumerable and Collectable, allowing it to be used for both read and write.

The device is iterated by the given number of characters or line by line if :line is given.

This reads from the IO as UTF-8. Check out IO.binstream/2 to handle the IO as a raw binary.

Note that an IO stream has side effects and every time you go over the stream you may get different results.

Examples

Here is an example on how we mimic an echo server from the command line:

Enum.each(IO.stream(:stdio, :line), &IO.write(&1))