instance method
String#chomp!
(nil) -> nil
(?::string? separator) -> self?
chomp!(line_sep = $/) → self or nil
string.c
View on GitHub ↗
static VALUE
rb_str_chomp_bang(int argc, VALUE *argv, VALUE str)
{
VALUE rs;
str_modifiable(str);
if (RSTRING_LEN(str) == 0 && argc < 2) return Qnil;
rs = chomp_rs(argc, argv);
if (NIL_P(rs)) return Qnil;
return rb_str_chomp_string(str, rs);
}
Like String#chomp, except that:
-
Removes trailing characters from
self(not from a copy ofself). -
Returns
selfif any characters are removed,nilotherwise.
Related: see Modifying.