Commit f7e49f66 authored by Suyash's avatar Suyash Committed by Joe Tsai

sort: fix search descending order example

Change-Id: I27b82d8c63a06ddf7e148b15853aba24a22a6282
Reviewed-on: https://go-review.googlesource.com/29336Reviewed-by: default avatarJoe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 569340eb
......@@ -32,7 +32,7 @@ func ExampleSearch_descendingOrder() {
x := 6
i := sort.Search(len(a), func(i int) bool { return a[i] <= x })
if a[i] == x {
if i < len(a) && a[i] == x {
fmt.Printf("found %d at index %d in %v\n", x, i, a)
} else {
fmt.Printf("%d not found in %v\n", x, a)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment