diff options
| author | molivier <olivier.matthieu@gmail.com> | 2017-08-08 17:39:52 +0200 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2017-08-09 04:43:33 +0000 |
| commit | 8fb9cee3f1a6333ad50d7ca382e9a0bdafc1b5b6 (patch) | |
| tree | fc958e4dd77b4d1b71119a3b302640ae59db5f91 /src/strings | |
| parent | e93eb2843c6b6b8e0e6c5e9eb1a4417328055ec6 (diff) | |
| download | go-8fb9cee3f1a6333ad50d7ca382e9a0bdafc1b5b6.tar.xz | |
strings: add examples for Index functions
Change-Id: Ia0f0c8ab4f2f9e96faad6d88775ae19ca7fae53c
Reviewed-on: https://go-review.googlesource.com/53790
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Avelino <t@avelino.xxx>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/strings')
| -rw-r--r-- | src/strings/example_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/strings/example_test.go b/src/strings/example_test.go index f35452369d..ba67458d1f 100644 --- a/src/strings/example_test.go +++ b/src/strings/example_test.go @@ -166,6 +166,26 @@ func ExampleLastIndexAny() { // -1 } +func ExampleLastIndexByte() { + fmt.Println(strings.LastIndexByte("Hello, world", 'l')) + fmt.Println(strings.LastIndexByte("Hello, world", 'o')) + fmt.Println(strings.LastIndexByte("Hello, world", 'x')) + // Output: + // 10 + // 8 + // -1 +} + +func ExampleLastIndexFunc() { + fmt.Println(strings.LastIndexFunc("go 123", unicode.IsNumber)) + fmt.Println(strings.LastIndexFunc("123 go", unicode.IsNumber)) + fmt.Println(strings.LastIndexFunc("go", unicode.IsNumber)) + // Output: + // 5 + // 2 + // -1 +} + func ExampleJoin() { s := []string{"foo", "bar", "baz"} fmt.Println(strings.Join(s, ", ")) |
