From: Martin Sucha Date: Thu, 23 May 2019 18:34:17 +0000 (+0200) Subject: strings: clarify example of ContainsAny X-Git-Tag: go1.13beta1~203 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=db3255536cdbdba9d6f38da9c3bb1faf55f63277;p=gostls13.git strings: clarify example of ContainsAny I have seen code that literally copied the example like this: if strings.ContainsAny(s, "1 & 2 & 3") { The developer apparently thought that this is the way to specify multiple characters and I noticed this pattern being used in the example. Let's update the example so that it's clear how multiple Unicode code points should be specified. Change-Id: Id4d780555e521af62fb787a7950be1e60848cd95 Reviewed-on: https://go-review.googlesource.com/c/go/+/178737 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- diff --git a/src/strings/example_test.go b/src/strings/example_test.go index e31054a4e0..4f3a1ce8c6 100644 --- a/src/strings/example_test.go +++ b/src/strings/example_test.go @@ -47,12 +47,16 @@ func ExampleContains() { func ExampleContainsAny() { fmt.Println(strings.ContainsAny("team", "i")) - fmt.Println(strings.ContainsAny("failure", "u & i")) + fmt.Println(strings.ContainsAny("fail", "ui")) + fmt.Println(strings.ContainsAny("ure", "ui")) + fmt.Println(strings.ContainsAny("failure", "ui")) fmt.Println(strings.ContainsAny("foo", "")) fmt.Println(strings.ContainsAny("", "")) // Output: // false // true + // true + // true // false // false }