Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Kernel#chop
chop → $_
ruby.c
View on GitHub ↗
static VALUE
rb_f_chop(VALUE _)
{
VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern("chop"), 0, 0);
rb_lastline_set(str);
return str;
}
Equivalent to ($_.dup).chop!, except nil is never returned. See String#chop!. Available only when -p/-n command line option specified.