mirror of
https://github.com/golang/go.git
synced 2024-09-21 10:28:27 +00:00
slices: use strings.EqualFold in ExampleCompactFunc
Change-Id: Ie7d495b2a53520ce89b16bc8a66b81a3955bf32f Reviewed-on: https://go-review.googlesource.com/c/go/+/530635 Reviewed-by: Eli Bendersky <eliben@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
9f8f1ca5ad
commit
bcfaf2f00f
@ -51,9 +51,7 @@ func ExampleCompact() {
|
||||
|
||||
func ExampleCompactFunc() {
|
||||
names := []string{"bob", "Bob", "alice", "Vera", "VERA"}
|
||||
names = slices.CompactFunc(names, func(a, b string) bool {
|
||||
return strings.ToLower(a) == strings.ToLower(b)
|
||||
})
|
||||
names = slices.CompactFunc(names, strings.EqualFold)
|
||||
fmt.Println(names)
|
||||
// Output:
|
||||
// [bob alice Vera]
|
||||
|
Loading…
Reference in New Issue
Block a user