VOOZH about

URL: https://apidock.com/ruby/String/delete_suffix

⇱ String#delete_suffix - APIdock


method

delete_suffix

ruby latest stable - Class: String
delete_suffix(p1)
public

Returns a copy of str with trailing suffix deleted.

"hello".delete_suffix("llo") #=> "he"
"hello".delete_suffix("hel") #=> "hello"
static VALUE
rb_str_delete_suffix(VALUE str, VALUE suffix)
{
 long suffixlen;

 suffixlen = deleted_suffix_length(str, suffix);
 if (suffixlen <= 0) return rb_str_dup(str);

 return rb_str_subseq(str, 0, RSTRING_LEN(str) - suffixlen);
}

Related methods