Ruby scan/gets until EOF

eof, ruby

Solution

Use `IO#read` (without `length` argument, it reads until EOF)

lines = STDIN.read

or use `gets` with `nil` as argument:

lines = gets(nil)

To denote EOF, type Ctrl + D (Unix) or Ctrl + Z (Windows).

Problem

I want to scan unknown number of lines till all the lines are scanned. How do I do that in ruby? For ex: ``` put returns between paragraphs for linebreak add 2 spaces at end _italic_ or **bold** ``` The input is not from a 'file' but through the STDIN.

Original source