Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ed8972f

Browse files
committed
use same function for all types
1 parent ae75e5d commit ed8972f

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

coderd/util/slice/slice.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,8 @@ func Descending[T constraints.Ordered](a, b T) int {
121121
// fmt.Println(add) // [2]
122122
// fmt.Println(remove) // [3, 4]
123123
func SymmetricDifference[T comparable](a, b []T) (add []T, remove []T) {
124-
return Difference(b, a), Difference(a, b)
125-
}
126-
127-
// Difference returns the elements in 'a' that are not in 'b'.
128-
func Difference[T comparable](a []T, b []T) []T {
129-
return DifferenceFunc(a, b, func(a, b T) bool {
130-
return a == b
131-
})
124+
f := func(a, b T) bool { return a == b }
125+
return SymmetricDifferenceFunc(a, b, f)
132126
}
133127

134128
func SymmetricDifferenceFunc[T any](a, b []T, equal func(a, b T) bool) (add []T, remove []T) {

0 commit comments

Comments
 (0)