1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #19121 from davydovanton/update-doc-for-remove

Update documentation examples for String#remove [skip ci]
This commit is contained in:
Yves Senn 2015-02-28 12:15:08 +01:00
commit b58dac811b

View file

@ -26,6 +26,7 @@ class String
# Returns a new string with all occurrences of the patterns removed.
# str = "foo bar test"
# str.remove(" test") # => "foo bar"
# str.remove(" test", /bar/) # => "foo "
# str # => "foo bar test"
def remove(*patterns)
dup.remove!(*patterns)
@ -33,8 +34,8 @@ class String
# Alters the string by removing all occurrences of the patterns.
# str = "foo bar test"
# str.remove!(" test") # => "foo bar"
# str # => "foo bar"
# str.remove!(" test", /bar/) # => "foo "
# str # => "foo "
def remove!(*patterns)
patterns.each do |pattern|
gsub! pattern, ""