Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

String#delete_suffix

str.delete_suffix(suffix) → new_str

Returns a copy of str with trailing suffix deleted.

Example
"hello".delete_suffix("llo") #=> "he"
"hello".delete_suffix("hel") #=> "hello"

Ruby version changes

  1. 3.0