VOOZH about

URL: https://apidock.com/ruby/String/slice!

⇱ String#slice! - APIdock


method

slice!

ruby latest stable - Class: String
slice!(*args)
public

Deletes the specified portion from str, and returns the portion deleted.

string = "this is a string"
string.slice!(2) #=> "i"
string.slice!(3..6) #=> " is "
string.slice!(/s.*t/) #=> "sa st"
string.slice!("r") #=> "r"
string #=> "thing"
static VALUE
rb_str_slice_bang(int argc, VALUE *argv, VALUE str)
{
 VALUE result;
 VALUE buf[3];
 int i;

 rb_check_arity(argc, 1, 2);
 for (i=0; i<argc; i++) {
 buf[i] = argv[i];
 }
 str_modify_keep_cr(str);
 result = rb_str_aref_m(argc, buf, str);
 if (!NIL_P(result)) {
 buf[i] = rb_str_new(0,0);
 rb_str_aset_m(argc+1, buf, str);
 }
 return result;
}

Related methods