chop()
public
Show source
/*
* call-seq:
* chop => string
*
* Equivalent to <code>($_.dup).chop!</code>, except <code>nil</code>
* is never returned. See <code>String#chop!</code>.
*
* a = "now\r\n"
* $_ = a
* chop
* $_
* chop
* chop
* chop
* chop
* a
*/
static VALUE
rb_f_chop()
{
VALUE str = uscore_get();
if (RSTRING(str)->len > 0) {
str = rb_str_dup(str);
rb_str_chop_bang(str);
rb_lastline_set(str);
}
return str;
}