underscore/difference.go
Ruidy 6b377350d6
U 21 diff (#23)
* add logo and fix project image description

* add difference function

* update docs

Co-authored-by: Ruidy <rnemausat@newstore.com>
2022-03-24 17:30:01 +01:00

8 lines
264 B
Go

package underscore
// Difference Returns a copy of the array with all instances of the values that are not present in the other array.
func Difference[T comparable](slice, other []T) []T {
return Filter(slice, func(n T) bool {
return !Contains(other, n)
})
}