In https://bugs.ruby-lang.org/issues/12694, we decided to have
It would be nice to have
String#delete_suffix method to delete suffix from a string for symmetry although it can be achieved with
class String def delete_suffix(substr) chomp(substr) end def delete_suffix!(substr) chomp!(substr) end end
Updated by nobu (Nobuyoshi Nakada) almost 3 years ago
- Description updated (diff)
At yesterday meeting, a name
lchomp was proposed but rejected because of the special deal of CR LF.
delete_suffix will be introduced, it should keep CR before LF when the argument is LF only, as well as
Updated by sonots (Naotoshi Seo) over 2 years ago
- Status changed from Open to Closed
Applied in changeset trunk|r59377.
string.c: add String#delete_suffix and String#delete_suffix!
to remove trailing suffix [Feature #13665] [Fix GH-1661]
string.c (rb_str_delete_suffix_bang): add a new method
to remove suffix destuctively.
string.c (rb_str_delete_suffix): add a new method
to remove suffix non-destuctively.
test/ruby/test_string.rb: add tests.