rstrip()
public
Returns a copy of str with trailing whitespace removed. See also
String#lstrip and String#strip.
Refer to strip for the definition of
whitespace.
" hello ".rstrip
"hello".rstrip
Show source
static VALUE
rb_str_rstrip(VALUE str)
{
rb_encoding *enc;
char *start;
long olen, roffset;
enc = STR_ENC_GET(str);
RSTRING_GETMEM(str, start, olen);
roffset = rstrip_offset(str, start, start+olen, enc);
if (roffset <= 0) return rb_str_dup(str);
return rb_str_subseq(str, 0, olen-roffset);
}