diff options
| author | Matthew Dempsky <mdempsky@google.com> | 2013-01-06 22:43:32 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2013-01-06 22:43:32 -0500 |
| commit | 8cf45909b59dbc9edf856b129c6b84603438973b (patch) | |
| tree | 9efea284ac16e2f34cdea6341d291c6461bb43c8 /src/pkg | |
| parent | a88bbbb771141598e492d123e15e1e9752c134ca (diff) | |
| download | go-8cf45909b59dbc9edf856b129c6b84603438973b.tar.xz | |
bytes: Change Compare example to be consistent with sort.Search's.
R=rsc, adg
CC=golang-dev
https://golang.org/cl/7057049
Diffstat (limited to 'src/pkg')
| -rw-r--r-- | src/pkg/bytes/example_test.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/pkg/bytes/example_test.go b/src/pkg/bytes/example_test.go index 5f7e18c9f6..dc66b6a40f 100644 --- a/src/pkg/bytes/example_test.go +++ b/src/pkg/bytes/example_test.go @@ -59,10 +59,10 @@ func ExampleCompare_search() { var needle []byte var haystack [][]byte // Assume sorted i := sort.Search(len(haystack), func(i int) bool { - // Return needle <= haystack[i]. - return bytes.Compare(needle, haystack[i]) <= 0 + // Return haystack[i] >= needle. + return bytes.Compare(haystack[i], needle) >= 0 }) - if i < len(haystack) && bytes.Equal(needle, haystack[i]) { + if i < len(haystack) && bytes.Equal(haystack[i], needle) { // Found it! } } |
