]> Cypherpunks repositories - gostls13.git/commitdiff
strings: add example for ContainsRune
authorKate Manson <kate.manson@izettle.com>
Sat, 15 Jul 2017 18:07:55 +0000 (12:07 -0600)
committerHeschi Kreinick <heschi@google.com>
Sat, 15 Jul 2017 18:20:05 +0000 (18:20 +0000)
Change-Id: I994f003c97a14d194df5f07dd217c0ff3b214741
Reviewed-on: https://go-review.googlesource.com/48874
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>

src/strings/example_test.go

index 3f9d63b5a4a3e7ba3a33e6e879bf19116a5e14e1..099d8c1cdca5dcb5504771445834517b03449b18 100644 (file)
@@ -47,6 +47,16 @@ func ExampleContainsAny() {
        // false
 }
 
+func ExampleContainsRune() {
+       // Finds whether a string contains a particular Unicode code point.
+       // The code point for the lowercase letter "a", for example, is 97.
+       fmt.Println(strings.ContainsRune("aardvark", 97))
+       fmt.Println(strings.ContainsRune("timeout", 97))
+       // Output:
+       // true
+       // false
+}
+
 func ExampleCount() {
        fmt.Println(strings.Count("cheese", "e"))
        fmt.Println(strings.Count("five", "")) // before & after each rune