From 8b0b7f5c67e080d0ff73744aaf37a4bec145443e Mon Sep 17 00:00:00 2001 From: Andy Long Date: Tue, 13 Jun 2023 10:56:11 +0100 Subject: [PATCH] Updating count to work with any so you can count structs as well as basic types --- count.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/count.go b/count.go index 581c053..9a3d287 100644 --- a/count.go +++ b/count.go @@ -2,7 +2,7 @@ package underscore // Count returns the number of elements in the slice that satisfy the predicate. // example: Count([]int{1,2,3,4,5}, func(n int) bool { return n%2 == 0 }) // 2 -func Count[T comparable](slice []T, predicate func(T) bool) int { +func Count[T any](slice []T, predicate func(T) bool) int { count := 0 for _, item := range slice { if predicate(item) {