]> Cypherpunks repositories - gostls13.git/commitdiff
strings: add example for LastIndexAny
authorEvan Hicks <evan.hicks2@gmail.com>
Sat, 15 Jul 2017 18:07:04 +0000 (12:07 -0600)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sat, 15 Jul 2017 20:31:52 +0000 (20:31 +0000)
Change-Id: I69d1359d8868d4c5b173e4d831e38cea7dfeb713
Reviewed-on: https://go-review.googlesource.com/48859
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/strings/example_test.go

index 099d8c1cdca5dcb5504771445834517b03449b18..fa34a8099f6bad5eeed0ad3e3324fe0c59519933 100644 (file)
@@ -137,6 +137,16 @@ func ExampleLastIndex() {
        // -1
 }
 
+func ExampleLastIndexAny() {
+       fmt.Println(strings.LastIndexAny("go gopher", "go"))
+       fmt.Println(strings.LastIndexAny("go gopher", "rodent"))
+       fmt.Println(strings.LastIndexAny("go gopher", "fail"))
+       // Output:
+       // 4
+       // 8
+       // -1
+}
+
 func ExampleJoin() {
        s := []string{"foo", "bar", "baz"}
        fmt.Println(strings.Join(s, ", "))