Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
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, but modifies self in place; returns nil if no modification made, self otherwise.