]> Cypherpunks.ru repositories - gostls13.git/commitdiff
strings: document that order of pairs matters in NewReplacer
authorFrancesco Renzi <rentziass@gmail.com>
Tue, 9 Jul 2019 13:43:10 +0000 (14:43 +0100)
committerRob Pike <r@golang.org>
Wed, 10 Jul 2019 21:26:21 +0000 (21:26 +0000)
Update NewReplacer documentation to specify that in the case of
multiple matches at the same position, the matching old/new
pair that appears first in NewReplacer arguments takes precedence.

Fixes #32699

Change-Id: I9d0616d28e5cd8c9bfa301be201f2b0ebf361dff
Reviewed-on: https://go-review.googlesource.com/c/go/+/185099
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/strings/replace.go

index ccab1fb861d3b3b07406b1f86a57931f5419f2ce..e28d42887930b9d852bdd2129c28f4ebf3bd8c8b 100644 (file)
@@ -25,7 +25,8 @@ type replacer interface {
 
 // NewReplacer returns a new Replacer from a list of old, new string
 // pairs. Replacements are performed in the order they appear in the
-// target string, without overlapping matches.
+// target string, without overlapping matches. The old string
+// comparisons are done in argument order.
 //
 // NewReplacer panics if given an odd number of arguments.
 func NewReplacer(oldnew ...string) *Replacer {