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() {
|
func ExampleCompactFunc() {
|
||||||
names := []string{"bob", "Bob", "alice", "Vera", "VERA"}
|
names := []string{"bob", "Bob", "alice", "Vera", "VERA"}
|
||||||
names = slices.CompactFunc(names, func(a, b string) bool {
|
names = slices.CompactFunc(names, strings.EqualFold)
|
||||||
return strings.ToLower(a) == strings.ToLower(b)
|
|
||||||
})
|
|
||||||
fmt.Println(names)
|
fmt.Println(names)
|
||||||
// Output:
|
// Output:
|
||||||
// [bob alice Vera]
|
// [bob alice Vera]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user