- Sort Score
- Result 10 results
- Languages All
Results 1 - 2 of 2 for ExampleIndexFunc (0.17 sec)
-
src/slices/example_test.go
// true } func ExampleIndex() { numbers := []int{0, 42, 8} fmt.Println(slices.Index(numbers, 8)) fmt.Println(slices.Index(numbers, 7)) // Output: // 2 // -1 } func ExampleIndexFunc() { numbers := []int{0, 42, -10, 8} i := slices.IndexFunc(numbers, func(n int) bool { return n < 0 }) fmt.Println("First negative at index", i) // Output: // First negative at index 2 }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Fri May 10 17:28:50 UTC 2024 - 8.1K bytes - Viewed (0) -
src/strings/example_test.go
// false // true } func ExampleIndex() { fmt.Println(strings.Index("chicken", "ken")) fmt.Println(strings.Index("chicken", "dmr")) // Output: // 4 // -1 } func ExampleIndexFunc() { f := func(c rune) bool { return unicode.Is(unicode.Han, c) } fmt.Println(strings.IndexFunc("Hello, 世界", f)) fmt.Println(strings.IndexFunc("Hello, world", f)) // Output: // 7 // -1 }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Mon Oct 09 22:05:38 UTC 2023 - 10.7K bytes - Viewed (0)