diff options
author | Francisco Rojas <francisco.rojas.gallegos@gmail.com> | 2017-07-15 14:32:15 -0600 |
---|---|---|
committer | Heschi Kreinick <heschi@google.com> | 2017-07-15 20:44:10 +0000 |
commit | 0b62ebfdec2aa95a57ad552fe965407e9cdba6fb (patch) | |
tree | 4c652885abb4756b34d5d393a21c0339bfe5a3ae | |
parent | 6bfd2d19ffa5b9700e1ddc8744bdfedf40d2b705 (diff) | |
download | go-0b62ebfdec2aa95a57ad552fe965407e9cdba6fb.tar.gz go-0b62ebfdec2aa95a57ad552fe965407e9cdba6fb.zip |
strings: add a example for Compare func
Add a example for string.Compare that return the three possible results.
Change-Id: I103cf39327c1868fb249538d9e22b11865ba4b70
Reviewed-on: https://go-review.googlesource.com/49011
Reviewed-by: Heschi Kreinick <heschi@google.com>
-rw-r--r-- | src/strings/example_test.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/strings/example_test.go b/src/strings/example_test.go index d9e31ea770..473b8c3833 100644 --- a/src/strings/example_test.go +++ b/src/strings/example_test.go @@ -23,6 +23,16 @@ func ExampleFieldsFunc() { // Output: Fields are: ["foo1" "bar2" "baz3"] } +func ExampleCompare() { + fmt.Println(strings.Compare("a", "b")) + fmt.Println(strings.Compare("a", "a")) + fmt.Println(strings.Compare("b", "a")) + // Output: + // -1 + // 0 + // 1 +} + func ExampleContains() { fmt.Println(strings.Contains("seafood", "foo")) fmt.Println(strings.Contains("seafood", "bar")) |