Method: String#chomp!

Defined in:
string.c

#chomp!(line_sep = $/) ⇒ self?

Like String#chomp, but modifies self in place; returns nil if no modification made, self otherwise.

Returns:

  • (self, nil)


10191
10192
10193
10194
10195
10196
10197
10198
10199
10200
# File 'string.c', line 10191

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);
}