instance method
String#lstrip!
() -> self?
lstrip!(*selectors) → self or nil
string.c
View on GitHub ↗
static VALUE
rb_str_lstrip_bang(int argc, VALUE *argv, VALUE str)
{
rb_encoding *enc;
char *start, *s;
long olen, loffset;
str_modify_keep_cr(str);
enc = STR_ENC_GET(str);
RSTRING_GETMEM(str, start, olen);
if (argc > 0) {
char table[TR_TABLE_SIZE];
VALUE del = 0, nodel = 0;
tr_setup_table_multi(table, &del, &nodel, str, argc, argv);
loffset = lstrip_offset_table(str, start, start+olen, enc, table, del, nodel);
}
else {
loffset = lstrip_offset(str, start, start+olen, enc);
}
if (loffset > 0) {
long len = olen-loffset;
s = start + loffset;
memmove(start, s, len);
STR_SET_LEN(str, len);
TERM_FILL(start+len, rb_enc_mbminlen(enc));
return str;
}
return Qnil;
}
Like String#lstrip, except that:
-
Performs stripping in
self(not in a copy ofself). -
Returns
selfif any characters are stripped,nilotherwise.
Related: see Modifying.