slice!(*args)
public
Deletes the specified portion from str, and returns the portion
deleted.
string = "this is a string"
string.slice!(2)
string.slice!(3..6)
string.slice!(/s.*t/)
string.slice!("r")
string
Show source
static VALUE
rb_str_slice_bang(int argc, VALUE *argv, VALUE str)
{
VALUE result;
VALUE buf[3];
int i;
if (argc < 1 || 2 < argc) {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1..2)", argc);
}
for (i=0; i<argc; i++) {
buf[i] = argv[i];
}
str_modify_keep_cr(str);
buf[i] = rb_str_new(0,0);
result = rb_str_aref_m(argc, buf, str);
if (!NIL_P(result)) {
rb_str_aset_m(argc+1, buf, str);
}
return result;
}