Method: Kernel#readline
- Defined in:
- io.c
#readline(sep = $/, chomp: false) ⇒ String #readline(limit, chomp: false) ⇒ String #readline(sep, limit, chomp: false) ⇒ String
Equivalent to method Kernel#gets, except that it raises an exception if called at end-of-stream:
$ cat t.txt | ruby -e "p readlines; readline"
["First line\n", "Second line\n", "\n", "Fourth line\n", "Fifth line\n"]
in `readline': end of file reached (EOFError)
Optional keyword argument chomp specifies whether line separators are to be omitted.
10451 10452 10453 10454 10455 10456 10457 10458 |
# File 'io.c', line 10451 static VALUE rb_f_readline(int argc, VALUE *argv, VALUE recv) { if (recv == argf) { return argf_readline(argc, argv, argf); } return forward(argf, rb_intern("readline"), argc, argv); } |