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
1 changed files with 3 additions and 2 deletions

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, ""