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:
commit
b58dac811b
1 changed files with 3 additions and 2 deletions
|
@ -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, ""
|
||||
|
|
Loading…
Reference in a new issue