End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
StringIO#gets
gets(sep = $/, chomp: false) → string or nil
gets(limit, chomp: false) → string or nil
gets(sep, limit, chomp: false) → string or nil
ext/stringio/stringio.c
View on GitHub ↗
static VALUE
strio_gets(int argc, VALUE *argv, VALUE self)
{
struct getline_arg arg;
VALUE str;
if (prepare_getline_args(&arg, argc, argv)->limit == 0) {
struct StringIO *ptr = readable(self);
return rb_enc_str_new(0, 0, get_enc(ptr));
}
str = strio_getline(&arg, readable(self));
rb_lastline_set(str);
return str;
}
Reads and returns a line from the stream; assigns the return value to $_; see Line IO.